centos 下 lnmp配置http自动跳转到https

正文开始

[md]

centos 下 lnmp配置http自动跳转到https

修改文件 /usr/local/nginx/conf/nginx.conf 增加以下对某个站点的配置 证书我用的阿里云的免费ssl证书

server{
    listen 80;
    server_name www.domain.cc domain.cc;
    rewrite ^(.*) https://$server_name$1 permanent;
}


server {
        listen 443 ssl;
        server_name www.domain.cc domain.cc;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/domain;
        #include router_rewrite.conf;
                location / {
                        if (!-e $request_filename) {
                                        rewrite ^(.*)$ /index.php?router=$1 last;
                        }
                }
                include enable-php.conf;

                index index.html;
                ssl_certificate   /etc/nginx/ssl/domain.cc.pem;
                ssl_certificate_key  /etc/nginx/ssl/domain.cc.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;





  location /wss
  {
    proxy_pass http://127.0.0.1:8282;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Real-IP $remote_addr;
  }

  # location / {} 站点的其它配置...
}

正文结束

Xshell实现Windows上传文件到Linux主机 定时任务