Skip to content

Commit 05e6029

Browse files
committed
update site
1 parent 24b3e90 commit 05e6029

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Nextcloud 的反向代理配置
2+
3+
默认情况下,官方似乎对非标准端口(80/443)特别讨厌,重定向总是会出现各种问题。但是若需要公网使用非标准端口的 https 反向代理,局域网使用 http,则需要一定的配置。
4+
5+
示例的环境如下,请根据你的实际情况调整:
6+
7+
- 局域网地址:`http://192.168.1.101:8000`
8+
- 公网地址:`https://nextcloud.example.com:10443`
9+
10+
## 配置 nginx {#nginx-config}
11+
12+
```
13+
server {
14+
listen 10443 ssl;
15+
http2 on;
16+
server_name nextcloud.example.com;
17+
18+
# 省略证书部分
19+
20+
location / {
21+
proxy_pass http://192.168.1.101:8000;
22+
23+
proxy_set_header Host $host:10443;
24+
proxy_set_header X-Forwarded-Proto https;
25+
proxy_set_header X-Forwarded-Port 10443;
26+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27+
}
28+
}
29+
```
30+
31+
## 配置 nextcloud {#nextcloud-config}
32+
33+
这里的核心是修改 `/var/www/html/config/config.php` 文件,docker 用户请调整你的文件路径。
34+
35+
```php
36+
<?php
37+
$protocol = (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 'https' : 'http';
38+
39+
$CONFIG = array (
40+
// 省略部分
41+
'trusted_proxies' =>
42+
array (
43+
0 => '192.168.1.1', // 反向代理服务器地址
44+
),
45+
'trusted_domains' =>
46+
array (
47+
0 => '192.168.1.101:8000',
48+
1 => 'nextcloud.example.com:10443',
49+
2 => 'nextcloud.example.com',
50+
),
51+
'overwrite.cli.url' => 'http://192.168.1.101:8000',
52+
'overwriteprotocol' => $protocol,
53+
);
54+
```

0 commit comments

Comments
 (0)