Nginx http重定向https

SSL证书申请的腾讯的,配置好证书后,直接监听80端口转发443就ok了

转发语句:rewrite ^/(.*) https://$server_name:443$request_uri? permanent;

#
# HTTPS server configuration
#
server {
    listen 80;
    server_name domain.com;
    rewrite ^/(.*) https://$server_name$request_uri? permanent;
}


server {
   listen       443 ssl http2 default_server;
   listen       [::]:443 ssl;
   server_name  domain.com;
    root /usr/share/wordpress;

   ssl_certificate 1_www.domain_bundle.crt;
   ssl_certificate_key 2_www.domain.key;
   ssl_session_cache shared:SSL:1m;
   ssl_session_timeout  10m;
   ssl_ciphers HIGH:!aNULL:!MD5;
   ssl_prefer_server_ciphers on;

   # Load configuration files for the default server block.
   include /etc/nginx/default.d/*.conf;

   location / {
       index index.php index.html index.htm;
        try_files $uri $uri/ /index.php index.php;
   }
   # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ .php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

   error_page 404 /404.html;
       location = /40x.html {
   }

   error_page 500 502 503 504 /50x.html;
       location = /50x.html {
   }
}


感谢大佬:https://blog.csdn.net/baofeidyz/article/details/80435929
感谢大佬:https://blog.csdn.net/a18827547638/article/details/89058358
感谢大佬:https://blog.csdn.net/wo18237095579/article/details/81121088

超详细补坑大佬:https://blog.csdn.net/smartdt/article/details/80027579

posted @ 2019-11-22 21:59  超级小白龙  阅读(182)  评论(0编辑  收藏  举报