1

I have deployed my SpringBoot application on two other servers, and I am using nginx as a reverse proxy to access these servers. I encountered an error when accessing dynamic content using nginx reverse proxy, while accessing static content was normal.

The following code is the nginx.conf file.

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    proxy_send_timeout  3600s;
    proxy_read_timeout  3600s;

    sendfile        on;

    keepalive_timeout  65;

    #gzip  on;
    upstream backend_server{
        server 172.22.56.180 weight=1;
        server 172.22.56.181 weight=1;
    }

    server {
        #error Connection timed out and 504 error
        large_client_header_buffers 4 16k;
        client_max_body_size 300m;
        client_body_buffer_size 128k;
        fastcgi_connect_timeout 600;
        fastcgi_read_timeout 600;
        fastcgi_send_timeout 600;
        fastcgi_buffer_size 64k;
        fastcgi_buffers   4 32k;
        fastcgi_busy_buffers_size 64k;
        fastcgi_temp_file_write_size 64k;

        proxy_pass_header Set-Cookie;
        proxy_redirect     off;
        proxy_hide_header  Vary;
        proxy_set_header   Accept-Encoding '';
        proxy_ignore_headers Cache-Control Expires;
        proxy_set_header   Referer $http_referer;
        proxy_set_header   Host   $host;
        proxy_set_header   Cookie $http_cookie;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /resources/ {
            alias  /usr/local/openresty/nginx/html/resources/;
            index  index.html index.htm;
        }

        location / {
                proxy_pass http://backend_server;
                proxy_set_header Host $http_host:$proxy_port;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                uwsgi_send_timeout 600;        # 指定向uWSGI传送请求的超时时间,完成握手后向uWSGI传>送请求的超时时间。
                uwsgi_connect_timeout 600;   # 指定连接到后端uWSGI的超时时间。
                uwsgi_read_timeout 600;
        }
        
        error_page   500 502 503 504  /resources/50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

Any help would be highly appreciated.

GingerJ
  • 11
  • 2

0 Answers0