你这是填在 listen 443;内了吧。。
我是直接用 listen 80; 然后直接 return 301 。
listen 443 则按正常来,贴一下我的配置文件
server {
listen 80;
index index.php index.htm index.html;
root /var/www/html;
return 301
https://www.hardwareunion.com$request_uri;
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/var/run/phpfpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
server {
listen 443 ssl http2;
index index.php index.htm index.html;
root /var/www/html;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_certificate /etc/nginx/1.crt;
ssl_certificate_key /etc/nginx/1.key;
ssl_ct on;
ssl_ct_static_scts /etc/nginx/sct1;
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/var/run/phpfpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}