我有一台使用 Nginx 反向代理进行 WAN 访问的 Synology NAS。由于子域cloud.domain.com
路由到 Synology,因此所有子文件夹路径均由 Synology 应用程序管理。
要访问文件管理器,我将使用以下 URL:
https://cloud.example.org/files
我在文件管理器中有一个共享文件夹,它使用 tinyURL 样式的链接进行直接访问。我想构建一个重定向,使用自定义 URL 直接指向此共享文件夹,如下所示:
https://cloud.example.org/public_downloads
换句话说,我需要使用https://cloud.example.org/public_downloads
来访问https://tiny.url/abcd123
。有没有办法覆盖特定的子文件夹路径而不破坏 Synology 管理的路径,例如/files
?
我查看了类似的问题nginx 重定向特定子域和路径,但在查看链接的文档后,我不知道如何为路径而不是子域配置它/
。我怀疑关键在于操纵location
我服务器的 Nginx 配置部分cloud.example.org
。
我的 Synology Nginx 配置
## CLOUD HTTPS ##
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name cloud.domain.com;
ssl_session_timeout 30m;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_certificate /usr/share/nginx/ssl/example.org-chain.pem;
ssl_certificate_key /usr/share/nginx/ssl/example.org-key.pem;
ssl_session_cache shared:SSL:10m;
add_header X-Xss-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
proxy_hide_header X-Powered-By;
add_header 'Referrer-Policy' 'no-referrer';
add_header Content-Security-Policy "frame-ancestors example.org app.example.org;";
location / {
proxy_pass http://10.1.2.3:5000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 90;
proxy_redirect http://synologyhostname:5000 https://$host/:5001;
}
}
## END CLOUD HTTPS ##