centos – nginx配置 – 可从外部localhost访问

我在我的nginx.conf中有这个

server {
      listen 80;
      server_name localhost;
      root /opt/myapp/public;
      passenger_enabled on;
}

问题是我可以从运行它的计算机访问webapp,但不能从网络中的任何其他计算机访问.有任何想法吗?

在CentOS 5.6上运行

最佳答案
‘server_name localhost’使得nginx要求Host头为’localhost’,即要求客户端尝试使用’http://localhost‘来访问它,因此只能在localhost本身上工作:-).
要么不输入server_name,要么使用其他主机将识别它的那个(fqdn,IP等).
http://wiki.nginx.org/VirtualHostExample

dawei

【声明】:淮南站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。