nginx http强制跳转https配置文件

server {

        listen 80;
        listen [::]:80;
        server_name xxxx.com;

        rewrite ^(.*)$  https://$host$1 permanent;

}
server {

        listen 443 ssl;

        server_name   xxx.com la998.com;

        #rewrite ^(.*)$  https://$host$1 permanent;

        ssl on;
        ssl_certificate   cert/213972949720863.pem;
        ssl_certificate_key  cert/213972949720863.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

        root /www/www.xxxxx.com;

        index index.php index.html;

        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                # With php7.0-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php7.0-fpm:
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
        location ~ /\.ht {
                deny all;
        }
}

 

发表评论