apiVersion: apps/v1 kind: Deployment metadata: name: seo-frontend namespace: seo-image-renamer labels: app: seo-frontend component: frontend spec: replicas: 2 strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 1 selector: matchLabels: app: seo-frontend template: metadata: labels: app: seo-frontend component: frontend spec: containers: - name: frontend image: nginx:1.21-alpine ports: - containerPort: 80 name: http resources: requests: memory: "64Mi" cpu: "100m" limits: memory: "128Mi" cpu: "200m" livenessProbe: httpGet: path: / port: 80 initialDelaySeconds: 10 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 3 readinessProbe: httpGet: path: / port: 80 initialDelaySeconds: 5 periodSeconds: 5 timeoutSeconds: 3 successThreshold: 1 failureThreshold: 3 volumeMounts: - name: nginx-config mountPath: /etc/nginx/nginx.conf subPath: nginx.conf - name: frontend-files mountPath: /usr/share/nginx/html volumes: - name: nginx-config configMap: name: nginx-config - name: frontend-files configMap: name: frontend-files restartPolicy: Always --- apiVersion: v1 kind: Service metadata: name: seo-frontend-service namespace: seo-image-renamer labels: app: seo-frontend spec: selector: app: seo-frontend ports: - name: http port: 80 targetPort: 80 protocol: TCP type: ClusterIP --- apiVersion: v1 kind: ConfigMap metadata: name: nginx-config namespace: seo-image-renamer data: nginx.conf: | events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https://js.stripe.com https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; img-src 'self' data: https:; connect-src 'self' https://api.seo-image-renamer.com wss://api.seo-image-renamer.com https://api.stripe.com;" always; # API proxy location /api/ { proxy_pass http://seo-api-service/api/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_connect_timeout 30s; proxy_send_timeout 30s; proxy_read_timeout 30s; } # WebSocket proxy location /socket.io/ { proxy_pass http://seo-api-service/socket.io/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # Static files location / { try_files $uri $uri/ /index.html; expires 1y; add_header Cache-Control "public, immutable"; } # Health check location /health { access_log off; return 200 "healthy\n"; add_header Content-Type text/plain; } } }