如果想要301你可以跟我 一样设置两个server段即可
server{
listen 80;
server_name mrhee.com www.mrhee.com;
return 301 https://mrhee.com$request_uri;
}
server
{
listen 443 ssl http2;
server_name mrhee.com www.mrhee.com;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/mrhee.com;
#error_page 404/404.html;
limit_conn perserver 200;
limit_conn perip 20;
limit_rate 314k;
ssl_certificate /etc/letsencrypt/live/mrhee.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mrhee.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
#openssl dhparam -out /www/server/nginx/conf/dhparam.pem 2048
ssl_dhparam /www/server/nginx/conf/dhparam.pem;
if ($server_port !~ 443){
rewrite ^/.*$ https://$host$uri;
}
error_page 497 https://$host$uri;
error_page 502 /502.html;
include enable-php-70.conf;
include /www/server/panel/vhost/rewrite/mrhee.com.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$
{
expires 12h;
access_log off;
}
access_log /www/wwwlogs/mrhee.com.log;
}
|