› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
MyFaith
V2EX  ›  NGINX

nginx 不带 www 可以正常访问, www 域名不能正常访问

  •  
  •   MyFaith ·
    MyFaith · Jun 30, 2016 · 7117 views
    This topic created in 3781 days ago, the information mentioned may be changed or developed.

    一旦访问 www 域名就会跳转到 域名访问提示

    图片描述

    域名已经解析 www 了,下面是nginx.conf

    user              nginx;
    worker_processes  1;
    
    error_log  /var/log/nginx/error.log;
    #error_log  /var/log/nginx/error.log  notice;
    #error_log  /var/log/nginx/error.log  info;
    
    pid        /var/run/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';    
        access_log  /var/log/nginx/access.log  main;
        sendfile        on;
        #tcp_nopush     on;
        #keepalive_timeout  0;
        keepalive_timeout  65;
        #gzip  on;
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*.conf;
    }
    

    sites-enabled

    server {
        listen 80;
        server_name www.youzisq.com youzisq.com;
    
        location / {
            proxy_pass http://127.0.0.1:5050;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    
    9 replies  •  2016-06-30 14:21:54 +08:00
    alex321
    alex321
    Jun 30, 2016
    1
    首先检查 www 解析(或者解析生效)没呃。。。。
    jswh
    jswh
    Jun 30, 2016
    2
    是不是 nginx 没 reload 配置
    shulen
    shulen
    Jun 30, 2016❤️1
    3
    我觉得是域名解析不成功, nginx 配置是没有问题的
    MyFaith
    MyFaith
    OP
    Jun 30, 2016
    4
    @alex321 解析应该是正常的,之前没用 nginx 的时候,加端口访问,是可以访问的,用了 nginx 之后,就这样了。
    MyFaith
    MyFaith
    OP
    Jun 30, 2016
    5
    @MyFaith 解析应该是正常的,之前没用 nginx 的时候,加端口访问,是可以访问的,用了 nginx 之后,就这样了。
    MyFaith
    MyFaith
    OP
    Jun 30, 2016
    6
    @jswh nginx -s reload 吗?执行过,还重启过。
    MyFaith
    MyFaith
    OP
    Jun 30, 2016
    7
    @alex321
    @jswh
    @shulen
    刚刚解决了,是 DNS 缓存。谢谢各位。
    AMST
    AMST
    Jun 30, 2016
    8
    表示可以访问 www 了
    wingoo
    wingoo
    Jun 30, 2016
    9
    dns 没生效吧
    我这边 访问两个都是好的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1031 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 23:06 · PVG 07:06 · LAX 15:06 · JFK 18:06
    ♥ Do have faith in what you're doing.