我正在做反向代理:
server {
listen 90 ssl;
server_name 192.168.5.11;
location /myshop/ {
proxy_pass http://192.168.5.10:80/another_shop/;
proxy_set_header Host $host:$server_port;
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;
add_header Front-End-Https on;
proxy_read_timeout 90;
proxy_redirect off;
}
}
当我访问https://192.168.5.11:90/myshop/在 $_SERVER['REQUEST_URI'] 中,我有 /another_shop/ 而不是“虚拟” nginx 位置 /myshop/
答案1
在 nginx 配置中添加以下几行
location /myshop/ {
proxy_pass http://127.0.0.1:80;
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 https;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header Host $host;
#proxy_connect_timeout 86400;
#proxy_send_timeout 86400;
#proxy_read_timeout 86400;
#send_timeout 86400;
#client_max_body_size 50m;
#client_body_buffer_size 16k;
}