遗憾的是,NextCloud没有给出官方的代理配置,代理配置来自Putting the snap behind a reverse proxy · nextcloud-snap↗和Configuring reverse proxy for Nextcloud – ONLYOFFICE↗。
具体配置如下:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /path/to/crt;
ssl_certificate_key /path/to/key;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
proxy_pass_header Server;
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;
proxy_pass http://127.0.0.1:80;
}
location /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav;
}
}
其中SSL配置部分来自Nginx 服务器 SSL 证书安装部署↗,需要注意的是其中提到了由于版本问题,配置文件可能存在不同的写法。例如:Nginx 版本为 nginx/1.15.0 以上请使用 listen 443 ssl 代替 listen 443 和 ssl on。
另外反向代理地址部分配置IP地址即可正常运行。
最后注意根据官方建议↗配置WebDav需要的well-known/caldav
和在config.php
中配置可信主机。