File tree Expand file tree Collapse file tree 9 files changed +49
-4
lines changed
Expand file tree Collapse file tree 9 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ proxy_set_header Connection "upgrade";
7878如果使用了 HTTPS,则还需要增加配置:
7979
8080``` properties showLineNumbers
81- proxy_set_header X-Forwarded-Proto https ;
81+ proxy_set_header X-Forwarded-Proto $scheme ;
8282```
8383
8484图略,参考上图宝塔设置。
Original file line number Diff line number Diff line change 5151第一次配置需重建容器后生效,之后修改配置文件 ` application.properties ` 的话,重启容器即可生效。
5252
5353
54- > 注意:如果你使用 9.x 的宝塔,可能会遇到宝塔的一个 bug,导致直链/短链跳转到 127.0.0.1,解决方法是在** 宝塔上** 修改这个站点配置文件(不是ZFile配置文件),将 ` proxy_set_header Host 127.0.0.1:$server_port; ` 修改为 ` proxy_set_header Host $host; ` ,保存即可。
54+ > 注意:如果你使用 9.x 的宝塔,可能会遇到宝塔的一个 bug,导致直链/短链跳转到 127.0.0.1,解决方法是在** 宝塔上** 修改这个站点配置文件(不是ZFile配置文件),将 ` proxy_set_header Host 127.0.0.1:$server_port; ` 修改为 ` proxy_set_header Host $host:$server_port ; ` ,保存即可。
5555 <img className={'sm:w-6/12 '} src="/img/2024/12/5/baota-fix1.png"> </img >
5656 <img className={'sm:w-6/12 '} src="/img/2024/12/5/baota-fix2.png"> </img >
5757
58+ 如果你的站点是 HTTPS 的,还建议你添加一行 ` proxy_set_header X-Forwarded-Proto $scheme; ` 到上面红框的下一行,不然可能直链会先跳转到 HTTP,再跳转到 HTTPS,会被浏览器提示不安全链接。
59+
5860## 其他设置
5961
6062宝塔 ` nginx ` 默认只支持上传最大 ` 50MB ` 的文件,可去以下页面进行设置:
Original file line number Diff line number Diff line change @@ -56,10 +56,12 @@ import TOCInline from '@theme/TOCInline';
5656- 如果使用域名,这里就写域名,** 注意这里只写域名,不写协议和端口** 。
5757- 如果不需要使用域名,而是直接使用服务器IP和端口访问,** 这里什么都不需要写** 。
5858
59- > 注意:如果你使用 9.x 的宝塔,可能会遇到宝塔的一个 bug,导致直链/短链跳转到 127.0.0.1,解决方法是在** 宝塔上** 修改这个站点配置文件(不是ZFile配置文件),将 ` proxy_set_header Host 127.0.0.1:$server_port; ` 修改为 ` proxy_set_header Host $host; ` ,保存即可。
59+ > 注意:如果你使用 9.x 的宝塔,可能会遇到宝塔的一个 bug,导致直链/短链跳转到 127.0.0.1,解决方法是在** 宝塔上** 修改这个站点配置文件(不是ZFile配置文件),将 ` proxy_set_header Host 127.0.0.1:$server_port; ` 修改为 ` proxy_set_header Host $host:$server_port ; ` ,保存即可。
6060 <img className={'sm:w-6/12 '} src="/img/2024/12/5/baota-fix1.png"> </img >
6161 <img className={'sm:w-6/12 '} src="/img/2024/12/5/baota-fix2.png"> </img >
6262
63+ 如果你的站点是 HTTPS 的,还建议你添加一行 ` proxy_set_header X-Forwarded-Proto $scheme; ` 到上面红框的下一行,不然可能直链会先跳转到 HTTP,再跳转到 HTTPS,会被浏览器提示不安全链接。
64+
6365## 5.更新版本
6466
6567更新步骤如下:
Original file line number Diff line number Diff line change @@ -96,10 +96,12 @@ import TOCInline from '@theme/TOCInline';
9696</Tabs >
9797
9898
99- > 注意:如果你使用 9.x 的宝塔,可能会遇到宝塔的一个 bug,导致直链/短链跳转到 127.0.0.1,解决方法是在** 宝塔上** 修改这个站点配置文件(不是ZFile配置文件),将 ` proxy_set_header Host 127.0.0.1:$server_port; ` 修改为 ` proxy_set_header Host $host; ` ,保存即可。
99+ > 注意:如果你使用 9.x 的宝塔,可能会遇到宝塔的一个 bug,导致直链/短链跳转到 127.0.0.1,解决方法是在** 宝塔上** 修改这个站点配置文件(不是ZFile配置文件),将 ` proxy_set_header Host 127.0.0.1:$server_port; ` 修改为 ` proxy_set_header Host $host:$server_port ; ` ,保存即可。
100100 <img className={'sm:w-6/12 '} src="/img/2024/12/5/baota-fix1.png"> </img >
101101 <img className={'sm:w-6/12 '} src="/img/2024/12/5/baota-fix2.png"> </img >
102102
103+ 如果你的站点是 HTTPS 的,还建议你添加一行 ` proxy_set_header X-Forwarded-Proto $scheme; ` 到上面红框的下一行,不然可能直链会先跳转到 HTTP,再跳转到 HTTPS,会被浏览器提示不安全链接。
104+
103105## 5.更新版本
104106
105107更新步骤如下:
Original file line number Diff line number Diff line change 1+ # Nginx 反向代理配置
2+
3+ 先说解决办法,检查反向代理服务器是否有配置:
4+
5+ ``` bash
6+ proxy_set_header X-Forwarded-Host $host :$server_port ;
7+ proxy_set_header X-Forwarded-Proto $scheme ;
8+ ```
9+
10+ 如果没有或和** 上面不一致** ,请修改反向代理服务器配置文件,添加或修改上述两行。
11+
12+ 原因如图所示:
13+
14+ <img className = { ' sm:w-3/4' } src = ' /img/2025/7/13/http-proxy-header.png' />
15+
16+ ## 修改示例
17+
18+ ### 宝塔 PHP 项目
19+
20+ <img className = { ' sm:w-3/4' } src = ' /img/2025/7/13/baota-proxy-php.png' />
21+
22+ ### 宝塔其他项目
23+
24+ <img className = { ' sm:w-3/4' } src = ' /img/2025/7/13/baota-proxy-other.png' />
Original file line number Diff line number Diff line change @@ -254,6 +254,21 @@ const sidebars = {
254254 type : 'doc' ,
255255 label : '如何运行多个 ZFile 实例?'
256256 } ,
257+ {
258+ id : 'question/nginx-proxy-config' ,
259+ type : 'doc' ,
260+ label : '为什么我启用了 https,但直链下载会被重定向到 http?'
261+ } ,
262+ {
263+ id : 'question/nginx-proxy-config' ,
264+ type : 'doc' ,
265+ label : '为什么我通过域名访问的项目,但重定向到了项目内网地址?'
266+ } ,
267+ {
268+ id : 'question/nginx-proxy-config' ,
269+ type : 'doc' ,
270+ label : '为什么我启用了 https,但直链下载浏览器提示"此网站使用的不是安全链接,该文件可能已被篡改"'
271+ } ,
257272 {
258273 id : 'question/only-office-download-fail' ,
259274 type : 'doc' ,
You can’t perform that action at this time.
0 commit comments