Nginx配置同一个域名同时支持http与https两种方式访问

下面是基于http转https的完整配置:
server{
    #listen 80;
    listen 443;
    ssl on;
    server_name domain.com; //你的域名
    index index.html index.htm index.php default.html default.htm default.php;
    ssl_certificate /usr/local/nginx/cert/user.medsci-tech.com/214020580630662.pem;
    ssl_certificate_key /usr/local/nginx/cert/user.medsci-tech.com/214020580630662.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 /home/wwwroot/web/public;//项目根目录

    include laravel.conf;
    #error_page 404 /404.html;
    include enable-php.conf;

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${
        expires 30d;
    }

    location ~ .*\.(js|css)?${
        expires 12h;
    }
}

 server {
    listen 80;
    server_name domain.com;
    rewrite ^/(.*) https://$server_name$request_uri? permanent;    #重定向
 }
阅读更多
个人分类: nginx
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭