我正在尝试通过运行在 raspberry 上的 nginx 反向代理访问我的 synology nas web ui。Nginx 反向代理正在为其他东西工作,比如我的 ghost 博客。我复制/粘贴了设置以通过 nas.my.domain 访问我的 nas 的 192.168.0.123:5000,但我收到的是“Synology / 抱歉,页面未找到”而不是 DSM 的登录提示。
这是我的 nginx 的设置
upstream nas {
server 192.168.0.123:5001;
# server 192.168.0.123:5000; KO
# server 192.168.0.123; KO
}
server {
listen 80;
return 302 https://$server_name$request_uri;
}
server {
server_name nas.my.domain;
listen 443 ssl http2;
# listen [::]:443 ssl http2;
access_log /var/log/nginx/nas.access.log;
error_log /var/log/nginx/nas.error.log;
ssl_certificate /etc/letsencrypt/live/nas.my.domain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nas.my.domain/privkey.pem;
include /etc/nginx/include/diffie-hellman;
client_max_body_size 2m;
location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff|)$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
proxy_pass https://nas;
}
location / {
proxy_set_header HOST $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_pass https://nas;
proxy_redirect off;
proxy_buffering off;
}
}
在 nas 内部,我设置了控制面板/外部访问/高级,其中 nas.my.domain http = 80 和 https = 443。
请问有什么想法可以修复或解决这个问题吗?
此致,
答案1
我设法让它工作了,但不知道为什么
- 只有 443 端口有反应
- 之前都是白色的,直到我将所有标题从位置/到位置复制到图像缓存。
upstream nas {
server 192.168.0.123:443;
}
server {
listen 80;
return 302 https://$server_name$request_uri;
}
server {
server_name nas.my.domain;
listen 443 ssl http2;
# listen [::]:443 ssl http2;
access_log /var/log/nginx/nas.access.log;
error_log /var/log/nginx/nas.error.log;
ssl_certificate /etc/letsencrypt/live/nas.my.domain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nas.my.domain/privkey.pem;
include /etc/nginx/include/diffie-hellman;
client_max_body_size 2m;
location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff|)$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
proxy_set_header HOST $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_pass https://nas;
proxy_redirect off;
proxy_buffering off;
}
location / {
proxy_set_header HOST $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_pass https://nas;
proxy_redirect off;
proxy_buffering off;
}
}