全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2737|回复: 2

[nginx] Nginx访问http域名跳转到https怎么设置?

[复制链接]
发表于 2011-11-25 18:57:39 | 显示全部楼层 |阅读模式
新建了一个虚拟主机,虚拟主机的配置文件如下,网址替换了,怕怕
求访问xxx.com自动跳转到https://xxx.com
同时访问xxx.com/1.php能自动跳转到https://xxx.com/1.php
感激不尽
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name xxx.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/xxx.com;

  7.                 listen  443;
  8.                 server_name www.xxx.com xxx.com;
  9.                 index index.html index.htm index.php;
  10.                 error_page 404 403 http://xxx.com;
  11.                 ssl on;
  12.                 ssl_certificate /root/vision_im.crt;
  13.                 ssl_certificate_key /root/server.key;

  14.                 include wordpress.conf;
  15.                 location ~ .*\.(php|php5)?$
  16.                         {
  17.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  18.                                 fastcgi_index index.php;
  19.                                 include fcgi.conf;
  20.                         }

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

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

  29.                 log_format  xxx.com  '$remote_addr - $remote_user [$time_local] $request '
  30.              '$status $body_bytes_sent $http_referer '
  31.              '$http_user_agent $http_x_forwarded_for';
  32.                 access_log  /home/wwwlogs/xxx.com.log  xxx.com;
  33.         }
复制代码
发表于 2011-11-25 19:00:57 | 显示全部楼层
强制开启SSL(强制http转向https)
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name  域名;
  5.                 rewrite ^/(.*) https://域名/$1 permanent;
  6.         }

  7. server
  8.         {
  9.                 listen       443;
  10.                 server_name  域名;
  11.                 index index.html index.htm index.php;
  12.                 root  /home/wwwroot;

  13.                 ssl    on;
  14.                 ssl_certificate    /home/wwwroot/xxx.crt;
  15.                 ssl_certificate_key     /home/wwwroot/xxx.key;
  16.                 ssl_session_timeout 5m;

  17.         ssl_protocols SSLv2 SSLv3 TLSv1;
  18.         ssl_ciphers ALL:!ADH:!EXPOR***56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
  19.         ssl_prefer_server_ciphers   on;

  20.                 location ~ .*\.(php|php5)?$
  21.                         {
  22.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  23.                                 fastcgi_index index.php;
  24.                                 include fcgi.conf;
  25.                                 fastcgi_param  HTTPS on;
  26.                         }
复制代码
加分,谢谢

评分

参与人数 1威望 +15 收起 理由
一手好湿 + 15 谢了!!!!!

查看全部评分

发表于 2011-11-25 19:02:35 | 显示全部楼层
坐等技术帝
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-3 09:03 , Processed in 0.063249 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表