反向代理配置示例
1 http
或ws
反向代理配置
server {
...
# 指定 /tracker 路由进行反向到192.168.0.4:5088
location /tracker {
proxy_pass http://192.168.0.4:5088/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Remote_addr $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /graphql {
proxy_pass http://192.168.0.4:5080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Remote_addr $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
...
tip
这里要注意,如果是IP/Route的形式的话,在转发时也有路由重写包含在里面,
以上就是 /tracker --> 对应IP/ 而不是 /tracker --> IP/tracker
如果想要没有路由重写,则转发的目录ip就不要写路由了如: /tracker --> IP;意思是 /tracker 也会对应 IP/tacker