宝塔反代绑定127.0.0.1域名

  1. 先确保域名已经解析到你的服务器ip
  2. 打开宝塔-网站-添加站点
  3. 设置反代:宝塔-网站-点击域名-反向代理,设置值http://127.0.0.1:34567然后勾选启用反向代理
  4. 添加nginx配置:宝塔-网站-点击域名-配置文件。找到以下内容,添加以下三行。
location /
    {
        ...
        proxy_buffering off;
        proxy_cache off;
        proxy_set_header X-Forwarded-Proto $scheme;
        ...
    }

如图

#PROXY-START/
location /
{
proxy_pass http://127.0.0.1:81;
proxy_set_header Host 127.0.0;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;

#持久化连接相关配置
#proxy_connect_timeout 30s;
#proxy_read_timeout 86400s;
#proxy_send_timeout 30s;
#proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";

add_header X-Cache $upstream_cache_status;


expires 12h;
}
#PROXY-END/

 

参考:https://wiki.pyone.me/pyone-an-zhuang/bang-ding-yu-ming.html