间歇性问题在浏览器cookie Clearance获得502服务暂时不可用的服务&浏览器cookie Clearance 503 Badgateway nginx

发布于 2025-01-22 12:32:22 字数 2425 浏览 0 评论 0原文

我们的Kubernetes Pod带有两个容器(NGINX容器和应用程序容器)。我们已经将NGINX配置定义为配置映射以及deployment.yaml文件,并使用最新代码在每个Sprint中部署应用程序。

但是,在测试它时,我们正在遇到间歇性问题,并且在浏览器cookie Clearance获得502服务暂时不可用&浏览器cookie Clearance 503 badgateway nginx错误。

我们已经定义了大_client_header_buffers 4 16k;从nginx.conf中的默认值避免cookie的任何问题。仍然没有解决,并且仍然获得502服务暂时不可用&浏览器cookie清除503 badgateway nginx错误。如果有人可以提出解决方案来克服它,我将非常感谢。

这是我用于部署的文件:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{APP_NAME}}-nginx
  namespace: {{NAME_SPACE}}
data:
  nginx.conf: |
    user  nginx;
    worker_processes  1;
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    events {
        worker_connections  1024;
    }
    http {
        server_tokens off;
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        large_client_header_buffers 4 16k;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
        access_log  /var/log/nginx/access.log  main;
        sendfile        on;
        #tcp_nopush     on;
        keepalive_timeout  65;
        gzip  on;
        include /etc/nginx/conf.d/*.conf;
    }
  default.conf: |
    map $http_user_agent $ignore_ua {
      default                 1;
      "ELB-HealthChecker/2.0" 0;
      "kube-probe/1.21+"      0;
    }
    
    server {
       listen 3001 ssl;
       ssl_certificate     /etc/ssl/certs/ssc/ssc.crt;
       ssl_certificate_key /etc/ssl/certs/ssc/ssc.key;
       server_name         localhost;
       proxy_buffer_size          128k;
       proxy_buffers              4 256k;
       proxy_busy_buffers_size    256k;
       location ~* ^/(api/.+) {
          add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
          proxy_pass http://localhost:5000/$1$is_args$args;
          access_log /var/log/nginx/access.log combined if=$ignore_ua;
       }
       location / {
          proxy_http_version 1.1;
          proxy_hide_header Cache-Control;
          proxy_hide_header Expires;
          proxy_ignore_headers Cache-Control Expires;
          proxy_intercept_errors on;
          add_header Cache-Control "private, no-cache, no-store, max-age=0, must-revalidate";
          proxy_pass http://localhost:5000/;
       }
    }

We are having kubernetes pod with running two containers (Nginx container and Application container) inside it. We have defined nginx configuration as a config map along with deployment.yaml file and deploying application in each sprint with latest code.

But while testing it, we are getting intermittent issue and before browser cookies clearance getting 502 Service Temporarily Unavailable & after browser cookies clearance 503 BadGateway Nginx errors respectively.

we have defined large_client_header_buffers 4 16k; from default values in nginx.conf to avoid any issue with cookies. Still it is not resolved and still getting 502 Service Temporarily Unavailable & after browser cookies clearance 503 BadGateway Nginx errors. I'll highly appreciate if anybody can suggest a solution to overcome over it.

Here is the file I am using for deployment:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{APP_NAME}}-nginx
  namespace: {{NAME_SPACE}}
data:
  nginx.conf: |
    user  nginx;
    worker_processes  1;
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    events {
        worker_connections  1024;
    }
    http {
        server_tokens off;
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        large_client_header_buffers 4 16k;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
        access_log  /var/log/nginx/access.log  main;
        sendfile        on;
        #tcp_nopush     on;
        keepalive_timeout  65;
        gzip  on;
        include /etc/nginx/conf.d/*.conf;
    }
  default.conf: |
    map $http_user_agent $ignore_ua {
      default                 1;
      "ELB-HealthChecker/2.0" 0;
      "kube-probe/1.21+"      0;
    }
    
    server {
       listen 3001 ssl;
       ssl_certificate     /etc/ssl/certs/ssc/ssc.crt;
       ssl_certificate_key /etc/ssl/certs/ssc/ssc.key;
       server_name         localhost;
       proxy_buffer_size          128k;
       proxy_buffers              4 256k;
       proxy_busy_buffers_size    256k;
       location ~* ^/(api/.+) {
          add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
          proxy_pass http://localhost:5000/$1$is_args$args;
          access_log /var/log/nginx/access.log combined if=$ignore_ua;
       }
       location / {
          proxy_http_version 1.1;
          proxy_hide_header Cache-Control;
          proxy_hide_header Expires;
          proxy_ignore_headers Cache-Control Expires;
          proxy_intercept_errors on;
          add_header Cache-Control "private, no-cache, no-store, max-age=0, must-revalidate";
          proxy_pass http://localhost:5000/;
       }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文