NginX trailing slash in proxy pass url

前端 未结 2 432
梦如初夏
梦如初夏 2020-12-23 10:14

I know that this question has been asked multiple times but after a trying a lot of solutions I am still stuck.

I am using NginX to proxy pass to a NodeJs applicatio

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 10:46

    You might add these lines:

    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    

    Example, I proxy public port 80 to local port 880

    location / {
                proxy_redirect off;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_connect_timeout 90;
                proxy_send_timeout 90;
                proxy_read_timeout 90;
                proxy_buffer_size 16k;
                proxy_buffers 32 8k;
                proxy_busy_buffers_size 64k;
    
                proxy_pass   http://127.0.0.1:880/;
        }
    

    Note: Make sure to restart nginx. You might need to use another browser to test the new configuration (avoid cache)

提交回复
热议问题