【已解答】反向代理宝塔不成功
我们局域网内有两台服务器,都安装了宝塔面板,想实现反向代理访问其中的一台,但是不成功,是不支持?location /baota/ {
proxy_pass http://192.168.1.75:15043/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 关键:关闭压缩,否则 sub_filter 无法工作
proxy_set_header Accept-Encoding "";
# 自动为 HTML 添加 base 标签(对相对路径有效)
sub_filter_once off;
sub_filter '<head>' '<head><base href="/baota/">';
# 新增:替换 HTML 中的绝对路径
# 替换 href="/static/..." 为 href="/baota/static/..."
sub_filter 'href="/static/' 'href="/baota/static/';
# 替换 src="/static/..." 为 src="/baota/static/..."
sub_filter 'src="/static/' 'src="/baota/static/';
# 可以根据需要添加更多路径,例如 /api/, /css/ 等
# sub_filter 'src="/api/' 'src="/baota/api/';
}
可以尝试在网站---反向代理项目那里添加看看 阿珂 发表于 2025-10-14 14:57
可以尝试在网站---反向代理项目那里添加看看
网站这样设置,反向代理,可以正常访问,但是宝塔管理后台就不行,图片正常,js,css不正常 如果反代那里也不行的话,暂时不支持这种反代方式
页:
[1]