如有錯(cuò)誤,請(qǐng)指正。
nginx安裝和證書申請(qǐng):略
server {
listen 8081;
rewrite ^(.*)$ https://$host$1 permanent;
#error_page 497 https://$host$uri?$args;
}
server {
listen 443 ssl;
ssl_certificate ssl/abc.crt;
ssl_certificate_key ssl/abc.key;
server_name test.net www.test.net;
......
}
若使用非標(biāo)準(zhǔn)端口(如8443),則做如下修改
server {
listen 8081;
rewrite ^(.*)$ https://$host:8443 permanent;
}
server {
listen 8443 ssl;
ssl_certificate ssl/abc.crt;
ssl_certificate_key ssl/abc.key;
server_name test.net www.test.net;
......
}
網(wǎng)上說可以利用497的返回碼。這種方式經(jīng)過測(cè)試發(fā)現(xiàn)雖然跳轉(zhuǎn)了https,但是證書卻沒生效。暫時(shí)沒時(shí)間繼續(xù)深入研究。