美文网首页
Rancher中ingress常用配置解决nginx问题

Rancher中ingress常用配置解决nginx问题

作者: liurongming | 来源:发表于2021-09-30 15:43 被阅读0次
    # 解决重写问题
    # 访问带/api,proxy_pass时去掉/api
    # 减少配置,增加域名利用率
    # 单个配置
    nginx.ingress.kubernetes.io/configuration-snippet: rewrite /api/?(.*)$ /$1 break;
    # 多个配置
    nginx.ingress.kubernetes.io/configuration-snippet: |-
          rewrite /api/?(.*)$ /$1 break;
          rewrite /minio/?(.*)$ /$1 break;
    
    # 解决超载问题
    nginx.ingress.kubernetes.io/proxy-body-size: 100M
    
    # 解决504超时问题
    nginx.ingress.kubernetes.io/proxy-connect-timeout: 1200
    nginx.ingress.kubernetes.io/proxy-send-timeout: 1200
    nginx.ingress.kubernetes.io/proxy-read-timeout: 1200
    

    对应nginx配置

    server {
            listen 80;
            server_name xxx.xxx.com;
    
            ignore_invalid_headers off;
            # client_max_body_size 1000m;
            proxy_buffering off;
    
            location / {
                    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_set_header Host $http_host;
    
                    # proxy_connect_timeout 300;
                    proxy_http_version 1.1;
                    proxy_set_header Connection "";
                    chunked_transfer_encoding off;
    
                    ## 允许跨域
                    add_header Access-Control-Allow-Origin *;
                    add_header Access-Control-Allow-Headers X-Requested-With;
                    add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
    
                    # 调优
                    client_max_body_size    10240m;
                    client_body_buffer_size 256k;
                    proxy_connect_timeout 1200;
                    proxy_read_timeout  1200;
                    proxy_send_timeout  1200;
                    proxy_buffer_size  32k;
                    proxy_buffers   4 64k;
                    proxy_busy_buffers_size 128k;
                    proxy_temp_file_write_size 10m;
    
                    proxy_pass http://172.17.0.3:9000;
            }
    
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                    root   /usr/share/nginx/html;
            }
    }
    

    相关文章

      网友评论

          本文标题:Rancher中ingress常用配置解决nginx问题

          本文链接:https://www.haomeiwen.com/subject/eiuenltx.html