1.将申请到的ssl加密证书文件拷贝到nginx的conf目录下

   如:server.pem、server.key

2.vim nginx.conf

  例子:

  

server {
        listen       443 ssl;
        #listen       80;
        server_name  www.test.com;
        ssl_certificate      server.pem;
        ssl_certificate_key  server.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  10m;

        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
       ssl_ciphers RC4:HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;


        root  /mnt/html/test;
        index  index.php index.html index.htm;
        access_log    logs/test.com_access.log;
        error_log     logs/test.com_error.log debug;


         error_page   500 502 503 504  /50x.html;

         location = /50x.html {
            root   /mnt/html;
         }
        #重定向
        location / {
                if (!-e $request_filename) {
                        rewrite ^/(.*)$ /index.php/$1 last;
                }
        }
       
        location ~ \.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi.conf;
         }
        }

3.配置http重定向到https

server {
    listen  80;
    server_name www.test.com test.com;

    rewrite ^(.*)$  https://www.test.com$1 permanent;
}

4.重启nginx 搞定

相关文章:

  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-04-02
  • 2022-12-23
  • 2023-03-29
  • 2022-02-22
猜你喜欢
  • 2021-09-10
  • 2021-11-05
  • 2021-05-29
  • 2021-07-06
  • 2021-07-11
  • 2021-07-17
相关资源
相似解决方案