我已经完成了这些返回操作,但仍然无法将页面重定向到https。该站点托管在synology上,并在路径 / usr / local / etc / nginx / sites-enabled / 上创建了自定义配置文件。我已经使用Synology上的控制面板设置了https,现在我无法将http重定向到https。它什么也没做。
我还尝试在错误页面旁边添加 https:// $ server_name ,但它一直在添加端口号:5000。我真的不知道该去哪里。
server {
listen 80;
listen [::]:80;
server_name test.something.synology.me;
return 301 https://$server_name$request_uri;
location / {
return 301 https://$server_name$request_uri
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
proxy_intercept_errors off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
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://localhost:3001;
proxy_redirect http://localhost:3001 https://$server_name;
}
location ^~ /.well-known/acme-challenge {
root /var/lib/letsencrypt;
default_type text/plain;
}
error_page 403 404 500 502 503 504 @error_page;
location @error_page {
root /usr/syno/share/nginx;
rewrite (.*) /error.html break;
allow all;
}
}