宝塔面板nginx+Websockets 反代 实现本地中转/远程中转&HTTP和HTTPS互转
点击宝塔面板的网站名-反向代理-配置文件。
本地中转
记得修改端口55555:
location ^~ / {
proxy_redirect off;
proxy_pass http://127.0.0.1:55555;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
远程中转HTTPS
记得修改网址 xxx.com
location ^~ / {
proxy_pass https://xxx.com/abc;
proxy_set_header Host xxx.com:443;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
}
远程中转HTTP
记得修改网址 xxx.com
location /abc {
proxy_pass http://xxx.com/abc;
proxy_set_header Host xxx.com:80;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto http;
}
其他
中转使用CDN的网站,比如CF,需要增加2行代码
在反代的配置文件里面
两个location区块都加上:
记得修改网址 xxx.com
proxy_ssl_name xxx.com;
proxy_ssl_server_name on;
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。