问题背景:
开发配置nginx反向代理,发现一直不通;
location /proxy/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_pass http://my-server/; # 服务对应地址
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_read_timeout 60;
proxy_send_timeout 60;
}
curl http://localhost/proxy/hello
报404 问题
改成如下:
location /proxy/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_pass http://my-server/proxy/; # 服务对应地址
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_read_timeout 60;