• File: nginx.yaml
  • Full Path: /var/www/html/back/k8s/nginx.yaml
  • File size: 1.91 KB
  • MIME-type: text/plain
  • Charset: utf-8
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: gitep
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:alpine
          ports:
            - containerPort: 80
          volumeMounts:
            - name: nginx-config
              mountPath: /etc/nginx/conf.d
              readOnly: true
            - name: app-volume
              mountPath: /var/www/html
      volumes:
        - name: nginx-config
          configMap:
            name: nginx-config
        - name: app-volume
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  namespace: gitep
spec:
  selector:
    app: nginx
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
    - name: http-alternate
      protocol: TCP
      port: 8095
      targetPort: 8095
  type: LoadBalancer
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
  namespace: gitep
data:
  default.conf: |
    server {
        listen 80;
        listen [::]:80;
        server_name localhost;
        root /var/www/html/public;

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";

        index index.php;

        charset utf-8;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        error_page 404 /index.php;

        location ~ ^/index\.php(/|$) {
            fastcgi_pass app:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_hide_header X-Powered-By;
        }

        location ~ /\.(?!well-known).* {
            deny all;
        }
    }