VPS侦探论坛

 找回密码
 注册
查看: 10090|回复: 5

配置 ssl 出现了问题: chrome 军哥,浏览器显示 www.mydomain.com 将您重定向的次数过多

[复制链接]
发表于 2017-4-7 18:57:25 | 显示全部楼层 |阅读模式

环境: lnmp,申请了免费的腾讯 ssl 证书
我的 nginx.conf 配置如下:
  1. user www www;

  2. worker_processes auto;

  3. error_log /home/wwwlogs/nginx_error.log crit;

  4. pid /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200;

  6. events { use epoll; worker_connections 51200; multi_accept on; }

  7. http {

  8.     map $http_cf_ipcountry $allow {
  9.     default yes;
  10.     CN yes;
  11.     RU no;
  12.     US yes;
  13.     }
  14.     include       mime.types;
  15.     default_type  application/octet-stream;

  16.     server_names_hash_bucket_size 128;
  17.     client_header_buffer_size 32k;
  18.     large_client_header_buffers 4 32k;
  19.     client_max_body_size 50m;

  20.     sendfile   on;
  21.     tcp_nopush on;

  22.     keepalive_timeout 60;

  23.     tcp_nodelay on;

  24.     fastcgi_connect_timeout 300;
  25.     fastcgi_send_timeout 300;
  26.     fastcgi_read_timeout 300;
  27.     fastcgi_buffer_size 64k;
  28.     fastcgi_buffers 4 64k;
  29.     fastcgi_busy_buffers_size 128k;
  30.     fastcgi_temp_file_write_size 256k;

  31.     gzip on;
  32.     gzip_min_length  1k;
  33.     gzip_buffers     4 16k;
  34.     gzip_http_version 1.1;
  35.     gzip_comp_level 2;
  36.     gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
  37.     gzip_vary on;
  38.     gzip_proxied   expired no-cache no-store private auth;
  39.     gzip_disable   "MSIE [1-6]\.";

  40.     #limit_conn_zone $binary_remote_addr zone=perip:10m;
  41.     ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

  42.     server_tokens off;
  43.     access_log off;
  44. server {

  45. listen       80;

  46. server_name  www.mydomain.com;

  47. # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
  48. return 301 https://www.mydomain.com$request_uri;
  49. }

  50. server{

  51.    if ($allow = no) {
  52. return 403;
  53.   }

  54.    location ~ /.well-known {
  55.     allow all;
  56.     }

  57.      listen 443 default ssl;
  58.     #listen [::]:80 default_server ipv6only=on;
  59.     server_name www.mydomain.com;
  60.     ssl_certificate /usr/local/nginx/conf/1_www.mydomain.com_bundle.crt;
  61.     ssl_certificate_key /usr/local/nginx/conf/2_www.mydomain.com.key;
  62.     ssl_session_timeout 5m;
  63.     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  64.     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  65.     ssl_prefer_server_ciphers on;
  66.     index index.html index.htm index.php;
  67.     root  /home/wwwroot/default;

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

  70.     location /nginx_status
  71.     {
  72.         stub_status on;
  73.         access_log   off;
  74.     }

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

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




  83.     location ~ /\.
  84.     {
  85.         deny all;
  86.     }


  87.     access_log  /home/wwwlogs/access.log;
  88. }
  89. include vhost/*.conf; }
复制代码
参考了教程: https://www.v2ex.com/t/275074?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io
https://www.qcloud.com/document/product/400/4143#2.-nginx-.E8.AF.81.E4.B9.A6.E9.83.A8.E7.BD.B2
重启: lnmp nginx restart 出现警告:
toping nginx... nginx: [warn] conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored

[ 本帖最后由 fasefe 于 2017-4-7 18:59 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-4-8 09:12:20 | 显示全部楼层


该域名添加了多次
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-4-8 21:07:44 | 显示全部楼层

回复 2# 的帖子


怎么改呢军哥? /usr/local/nginx/conf/nginx.conf  里面的这个配置是否正确?另外我发现了/home/Richel/lnmp1.3-full/conf/nginx.conf 还有一个nginx.conf,这个文件做什么用的?里面的配置是:

user  www www;

worker_processes auto;

error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
         geoip_country /usr/share/GeoIP/GeoIP.dat;
         map $geoip_country_code $allowed_country {
         default no;
         FK yes;
         FM yes;
         EH yes;
         }
        include       mime.types;
        default_type  application/octet-stream;
client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";
server
    {
            if ($allowed_country = no) {
           return 403;
       }
          if ($http_cf_ipcountry = CN){
        return 403;
        }

        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name www.lnmp.org;
        index index.html index.htm index.php;
        root  /home/wwwroot/default;

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

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

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

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }
include vhost/*.conf;
}
   
问题可能出现在这里面吗?看到servername  www.lnmp.org ???
并且我在服务器上野找不到vhost文件夹,include里面也没有啊?一般情况下vhost会放在什么地方?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2017-4-8 21:25:52 | 显示全部楼层



输入了命令:lnmp vhost list :
Domain: www.mydomain.com has been deleted.
Website files will not be deleted for security reasons.
You need to manually delete the website files.

原因是否出现在这里?website files 在哪里?里面有配置2次域名的conf文件吗?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-4-8 21:59:41 | 显示全部楼层

回复 2# 的帖子


军哥现在我重启lnmp nginx restart没有这个警告了conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
但是依然是www.mydomain.com 将您重定向的次数过多。网站现在是无法打开的状态,输入服务器ip会自动跳转到https:www.mydomain.com

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

发表于 2017-4-9 09:45:18 | 显示全部楼层

回复 5# 的帖子


有可能是程序上还有301的设置
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-27 09:25 , Processed in 0.027283 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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