系統(tǒng):群暉7.2
1.SSH連接到nas扫俺, 輸入 sudo -i 獲取root權(quán)限固翰。
2.先備份要修改的文件
cp /usr/syno/share/nginx/WWWService.mustache /usr/syno/share/nginx/WWWService.mustache.bak
3.再輸入
vi /usr/syno/share/nginx/WWWService.mustache
4, 定位到最上面,
server { listen 80 default_server;
listen [::]:80 default_server;
server_name _;
gzip on;
改成以下內(nèi)容骂际,xxxxx是你要設(shè)置的域名. 注意泛域名前面有個.疗琉,二級域名不用。
server { listen 80 default_server;
listen [::]:80 default_server;
server_name domain.com *.domain.com;
return 301 https://$host$request_uri;
gzip on;
或者
server { listen 80 default_server;
listen [::]:80 default_server;
server_name domain.com *.domain.com;
rewrite ^(.*)$ https://$host$1 permanent;
gzip on;
修改完成后 systemctl restart nginx
重啟nginx歉铝。
參考鏈接:
1.https://www.bilibili.com/read/cv26559339/
2.https://www.myfreax.com/redirect-http-to-https-in-nginx/
3.https://segmentfault.com/a/1190000022532940
4.https://blog.csdn.net/HD243608836/article/details/112861186
5.https://www.nginx.com/blog/creating-nginx-rewrite-rules/
6.https://www.cnblogs.com/gaoyanbing/p/17411781.html