server 所有内容
server {
listen 80;
server_name webgis.xyz;
if ($scheme = http ) {
return 301 https://$host$request_uri; }
listen 443 ssl;
ssl_certificate webgis.xyz.crt;
ssl_certificate_key webgis.xyz.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8888/test/;
}
}
关键语句是:
if ($scheme = http ) {
return 301 https://$host$request_uri; }
即当使用http时,跳转到https
其他方法待补充