NPM反向代理CloudPanel面板报错502 Bad Gateway
情景
使用服务器A的Nginx Proxy Manager反代搭建在服务器B的CloudPanel面板上的站点。
情景参考:https://github.com/cloudpanel-io/cloudpanel-ce/issues/214
实际上官方于issue中给出了回复:
With the latest nginx update, we have added a default vhost to avoid direct ip access, see the following file:/etc/nginx/sites-enabled/default.conf
The proxy manager should work but make sure to forward the $HOST header.
解决方法
NPM反代的源站处设置:Advanced——Custom Nginx Configuration
location / {
proxy_pass $forward_scheme://$server:$port;
proxy_set_header Host $host;
proxy_ssl_name $host;
proxy_ssl_server_name on;
proxy_redirect $forward_scheme://$server:$port /;
}
方案来源:cloudpanel.io - Has anyone successfully configured npm infront of a website hosted on this platform?
此为有效解决办法,但由于本人小白,不明原理,故请理解的大佬留言。