【问题标题】:NGINX dns is not working on VPSNGINX dns 无法在 VPS 上运行
【发布时间】:2014-09-01 13:10:02
【问题描述】:

我对 VPS/Linux 有点陌生,所以请多多包涵。

我有一个指向主机名称服务器的域名 (attendahh.com)。

我已将 /etc/nginx/conf.d/attendahh.com.conf 设置如下:

# the IP(s) on which your node server is running. I chose port 3000.
upstream attendahh.com {
    server 127.0.0.1:1999;
}

# the nginx server instance
server {
    listen 0.0.0.0:80;
    server_name attendahh.com attendahh;
    access_log /var/log/nginx/attendahh.log;

    # pass the request to the node.js server with the correct headers and much $
    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://attendahh.com/;
      proxy_redirect off;
  }
}

那我service nginx restart。

我已经阅读了一堆教程和堆栈答案,这表面上是我需要做的,但如果我去http://attendahh.com 它不起作用。

注意事项:

  1. 在浏览器中访问我的 IP + 端口可以正常工作 (23.226.227.16:1999)
  2. 我安装了用于 VPS 的 Cpanel(我最初尝试在其中设置 DNS,但没有成功,我已经从那里删除了 dns 条目,但它可能仍然会影响事情)
  3. Apache virtual hosts 在 httpd.config 中被注释掉。

关于我在这里做错了什么有什么想法吗? apache和nginx之间可能有冲突?

【问题讨论】:

    标签: linux apache nginx dns centos


    【解决方案1】:

    Nginx 使用自己的解析器,它不使用系统的解析器(/etc/resolver)。

    您必须使用resolver 指令对其进行配置。如果您没有使用resolver 指令,则在proxy_pass 指令中使用IP 地址。

    来源:http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver

    【讨论】:

    • 你能给出一个我需要在这里更改的代码示例吗?文档并没有真正解释 mucnh。
    • 重新加载 Nginx 了吗?服务器可以连接到 : 吗?
    • 是的,我已经完成了service nginx restart,但没有运气。如何检查服务器是否可以连接到 :?
    • 是的,Curl 和 WGET 都可以正常工作。 Apache有没有可能挡道?
    • 尝试将其更改为proxy_pass http://23.226.227.16:1999;。 proxy_set_header 中的 Host 是否正确?当你说它什么都不做时,你看到了什么?检查访问和错误日​​志。
    【解决方案2】:
    -       proxy_pass http://attendahh.com/;
    +       proxy_pass http://attendahh.com;
    

    【讨论】:

    • 如果您阅读下面的答案,您会发现这没有任何效果。是否可以删除 Apache 和 Nginx 并从头开始?感觉好像发生了一些奇怪的事情。
    • 如何监听 :80 端口? Apache 还是 Nginx? netstat -lnpt | grep 80
    猜你喜欢
    • 1970-01-01
    • 2016-08-21
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多