VPS侦探论坛

 找回密码
 注册
查看: 9654|回复: 1

80端口怎么自动跳转到443端口?

[复制链接]
发表于 2014-9-17 09:02:05 | 显示全部楼层 |阅读模式

配置文件如下:
请问怎么输入http自动跳转到https呢?有ssl证书的了.
  1. server
  2.         {
  3.                 listen 443;
  4.                 #listen [::]:80;
  5.                 server_name www.domain.com;
  6.                 index index.html index.htm index.php default.html default.htm default.php;
  7.                 root  /mnt/data1/www/www. domain.com;

  8.                 include none.conf;
  9.                 #error_page   404   /404.html;
  10.                 ssl on;
  11.                 ssl_certificate /usr/local/nginx/certs/server2.crt;
  12.                 ssl_certificate_key /usr/local/nginx/certs/server2.key;

  13.                 location ~ [^/]\.php(/|$)
  14.                         {
  15.                                 # comment try_files $uri =404; to enable pathinfo
  16.                                 try_files $uri =404;
  17.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  18.                                 fastcgi_index index.php;
  19.                                 include fastcgi.conf;
  20.                                 fastcgi_param HTTPS on;
  21.                                 #include pathinfo.conf;
  22.                         }

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

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

  31.                 access_log  /home/wwwlogs/www. domain.com.log  access;
  32.         }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2014-9-17 19:59:24 | 显示全部楼层


301过去就行了

  1. server {
  2.     listen       80;
  3.     server_name  www.domain.com;
  4.     return       301 https://www.domain.com$request_uri;
  5. }
复制代码
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-26 03:30 , Processed in 0.024677 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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