V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
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 · 2016-06-30 14:00:10 +08:00 · 6125 次点击
    这是一个创建于 2828 天前的主题,其中的信息可能已经有所发展或是发生改变。

    一旦访问 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 条回复    2016-06-30 14:21:54 +08:00
    alex321
        1
    alex321  
       2016-06-30 14:03:48 +08:00
    首先检查 www 解析(或者解析生效)没呃。。。。
    jswh
        2
    jswh  
       2016-06-30 14:04:48 +08:00
    是不是 nginx 没 reload 配置
    shulen
        3
    shulen  
       2016-06-30 14:09:46 +08:00   ❤️ 1
    我觉得是域名解析不成功, nginx 配置是没有问题的
    MyFaith
        4
    MyFaith  
    OP
       2016-06-30 14:16:20 +08:00
    @alex321 解析应该是正常的,之前没用 nginx 的时候,加端口访问,是可以访问的,用了 nginx 之后,就这样了。
    MyFaith
        5
    MyFaith  
    OP
       2016-06-30 14:16:28 +08:00
    @MyFaith 解析应该是正常的,之前没用 nginx 的时候,加端口访问,是可以访问的,用了 nginx 之后,就这样了。
    MyFaith
        6
    MyFaith  
    OP
       2016-06-30 14:17:01 +08:00
    @jswh nginx -s reload 吗?执行过,还重启过。
    MyFaith
        7
    MyFaith  
    OP
       2016-06-30 14:20:55 +08:00
    @alex321
    @jswh
    @shulen
    刚刚解决了,是 DNS 缓存。谢谢各位。
    Leafove
        8
    Leafove  
       2016-06-30 14:21:30 +08:00
    表示可以访问 www 了
    wingoo
        9
    wingoo  
       2016-06-30 14:21:54 +08:00
    dns 没生效吧
    我这边 访问两个都是好的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3229 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:53 · PVG 21:53 · LAX 06:53 · JFK 09:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.