在 nginx 的配置文件中加入以下内容:
http {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://代理服务器地址:端口;
}
然后重启 nginx 服务即可。
如果需要全局代理,需要在http块中配置,如果只需要部分路由代理,可以在location块中配置.
在 nginx 的配置文件中加入以下内容:
http {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://代理服务器地址:端口;
}
然后重启 nginx 服务即可。
如果需要全局代理,需要在http块中配置,如果只需要部分路由代理,可以在location块中配置.