VPS侦探论坛

 找回密码
 注册
查看: 3820|回复: 7

请教军哥,https如何跳转到http

[复制链接]
发表于 2018-6-19 17:52:23 | 显示全部楼层 |阅读模式

请教军哥,之前用的lnmp配置的免费SSL证书,但是最近不知道怎么都过期了,索性就改回http,但是搜索引擎记录的都还是https页面,有没有办法自动跳转到http呢?从论坛看到http 301到https的方法,反向操作没成功。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-6-20 08:54:33 | 显示全部楼层


把http到https 的301设置反过来就行了
https 主机上设置301,http 是正常的虚拟主机就行了
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2018-6-20 20:15:39 | 显示全部楼层

回复 2# 的帖子


试了几次还是不行,请军哥看下下面的配置,
  1. server
  2.     {
  3.         listen 80;
  4.         #listen [::]:80;
  5.         server_name www.xxx.net xxx.net;
  6.         index index.html index.htm index.php default.html default.htm default.php;
  7.         root  /home/wwwroot/www.xxx.net;

  8.         include none.conf;
  9.         #error_page   404   /404.html;

  10.         # Deny access to PHP files in specific directory
  11.         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

  12.         include enable-php.conf;

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

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

  21.         location ~ /.well-known {
  22.             allow all;
  23.         }

  24.         location ~ /\.
  25.         {
  26.             deny all;
  27.         }

  28.         access_log  /home/wwwlogs/www.xxx.net.log;
  29. return 301 http://www.xxx.net$request_uri;
  30.     }

  31. server
  32.     {
  33.         listen 443 ssl http2;
  34.         #listen [::]:443 ssl http2;
  35.         server_name www.xxx.net ;
  36.         index index.html index.htm index.php default.html default.htm default.php;
  37.         root  /home/wwwroot/www.xxx.net;
  38. if ($host = 'xxx.net') {
  39.   return 301 http://www.xxx.net$request_uri;
  40. }
  41.         ssl on;
  42.         ssl_certificate /etc/letsencrypt/live/www.xxx.net/fullchain.pem;
  43.         ssl_certificate_key /etc/letsencrypt/live/www.xxx.net/privkey.pem;
  44.         ssl_session_timeout 5m;
  45.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  46.         ssl_prefer_server_ciphers on;
  47.         ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
  48.         ssl_session_cache builtin:1000 shared:SSL:10m;
  49.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  50.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

  51.         include none.conf;
  52.         #error_page   404   /404.html;

  53.         # Deny access to PHP files in specific directory
  54.         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

  55.         include enable-php.conf;

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

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

  64.         location ~ /.well-known {
  65.             allow all;
  66.         }

  67.         location ~ /\.
  68.         {
  69.             deny all;
  70.         }

  71.         access_log  /home/wwwlogs/www.xxx.net.log;
  72.     }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-6-21 08:36:47 | 显示全部楼层

回复 3# 的帖子




你这配置能成功才怪
http虚拟主机你加啥301,删掉
https虚拟主机里你加啥if,判断啥host,判断删掉只留301代码,另外server_name都没写全,none www的域名呢
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2018-6-21 08:47:52 | 显示全部楼层

回复 4# 的帖子


感谢军哥百忙之中还能回复,修改后貌似还是不行,代码如下:
  1. server
  2.     {
  3.         listen 80;
  4.         #listen [::]:80;
  5.         server_name www.xxx.net xxx.net;
  6.         index index.html index.htm index.php default.html default.htm default.php;
  7.         root  /home/wwwroot/www.xxx.net;

  8.         include none.conf;
  9.         #error_page   404   /404.html;

  10.         # Deny access to PHP files in specific directory
  11.         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

  12.         include enable-php.conf;

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

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

  21.         location ~ /.well-known {
  22.             allow all;
  23.         location ~ /\.
  24.         {
  25.             deny all;
  26.         }

  27.         access_log  /home/wwwlogs/www.xxx.net.log;
  28.     }

  29. server
  30.     {
  31.         listen 443 ssl http2;
  32.         #listen [::]:443 ssl http2;
  33.         server_name www.xxx.net xxx.net;
  34.         index index.html index.htm index.php default.html default.htm default.php;
  35.         root  /home/wwwroot/www.xxx.net;
  36.         return 301 http://www.xxx.net$request_uri;
  37.         ssl on;
  38.         ssl_certificate /etc/letsencrypt/live/www.xxx.net/fullchain.pem;
  39.         ssl_certificate_key /etc/letsencrypt/live/www.xxx.net/privkey.pem;
  40.         ssl_session_timeout 5m;
  41.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  42.         ssl_prefer_server_ciphers on;
  43.         ssl_session_cache builtin:1000 shared:SSL:10m;
  44.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  45.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

  46.         include none.conf;
  47.         #error_page   404   /404.html;

  48.         # Deny access to PHP files in specific directory
  49.         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

  50.         include enable-php.conf;

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

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

  59.         location ~ /.well-known {
  60.             allow all;
  61.         }

  62.         location ~ /\.
  63.         {
  64.             deny all;
  65.         }

  66.         access_log  /home/wwwlogs/www.xxx.net.log;
  67.     }
复制代码

军哥运维代购:http://shop63846532.taobao.com/

发表于 2018-6-21 18:02:20 | 显示全部楼层

回复 5# 的帖子


可能没重启或reload nginx,没有的话配置文件肯定不会生效
发表于 2018-6-21 21:04:03 | 显示全部楼层

做个猜想,会不会跟HSTS有关?比如之前设置过这个,时间又比较长,据说一旦进了这个目录,后头一直会以SSL加密方式走。

不过楼主为何不再继续申请和续SSL证书呢?一键包下,这个挺方便的,何况你引擎上收录的还已经是HTTPS了。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-6-22 10:26:42 | 显示全部楼层

回复 5# 的帖子


另外301也是有缓存的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-24 01:19 , Processed in 0.029156 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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