Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
562 views
in Technique[技术] by (71.8m points)

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

环境: lnmp,申请了免费的腾讯 ssl 证书

我的 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 {

    map $http_cf_ipcountry $allow {
    default yes;
    CN yes;
    RU no;
    US yes;
    }
    include       mime.types;
    default_type  application/octet-stream;

    server_names_hash_bucket_size 128;
    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].";

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

    server_tokens off;
    access_log off;
server {

listen       80;

server_name  www.mydomain.com;

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

server{

   if ($allow = no) {
return 403;
  }

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

     listen 443 default ssl;
    #listen [::]:80 default_server ipv6only=on;
    server_name www.mydomain.com.com;
    ssl_certificate /usr/local/nginx/conf/1_www.mydomain.com_bundle.crt;
    ssl_certificate_key /usr/local/nginx/conf/2_www.mydomain.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    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; }

参考了教程: https://www.v2ex.com/t/275074...

https://www.qcloud.com/docume...

重启: lnmp nginx restart 出现警告:

toping nginx... nginx: [warn] conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored

怎么办?怎么办?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

原因是:80端口重复配置了两次www.mydomain.com域名。
检查下配置。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...