相思资源网 Design By www.200059.com
Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的
server { listen 80; listen 443 ssl; ssl on; server_name 域名; index index.html index.htm index.php default.html default.htm default.php; ssl_certificate /usr/local/nginx/cert/21402058063066221.pem; //下载申请后阿里ssh提供的pem ssl_certificate_key /usr/local/nginx/cert/21402058063066221.key;//下载申请后阿里ssh提供的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/网站目录; include laravel.conf; //好吧,这里是laravel配置,不一定合适您哈,请或略 #error_page 404 /404.html; include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)"htmlcode">server { listen 80; server_name www.domain.com; rewrite ^/(.*) https://$server_name$1 permanent; #跳转到Https }重写依旧不同版本可能如下
rewrite ^/(.*)$ https://domain.com/$1 permanent;或者
rewrite ^ https://domain.com$request_uri"htmlcode">server { listen 80; server_name domain.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name domain.com; }但是我的nginx/1.10.0好像跑不起来,也许不支持这种写法吧...
下面是基于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; }
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无Nginx配置同一个域名同时支持http与https两种方式访问实现的评论...