监听端口80,但无法从centos 7.1上使用nginx的公共访问

监听端口80,但无法从centos 7.1上使用nginx的公共访问

问题描述:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      16146/nginx: master

nginx听了端口80。我的配置在 /etc/nginx/conf.d/default.conf

nginx did listen to port 80. Here is my config in /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  _;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ { ...

我使用公共ip在云主机上运行nginx,但是我无法从公共网络因为连接超时。

I'm running nginx on cloud host with a public ip, but I can't access that ip from public network because connection timeout.

首先:
使用tcpdump检查u是否尝试连接服务器u需要。 br>
at dest server:

tcpdump -i your_wan_if port 80 (例如: tcpdump -i venet0 port 80
本地主机上的


telnet external_ip 80

如果u会看到任何活动从ur ip - 好。

First: Use tcpdump to check if u trying to connect server u need.
at dest server:
tcpdump -i your_wan_if port 80 (Ex: tcpdump -i venet0 port 80)
at local host:
telnet external_ip 80
if u will see any activity from ur ip - nice.

第二:

检查selinux和防火墙。尝试禁用它们一段时间并检查。

Second:
check selinux and firewall. try to disable them for few moments and check.

(如果你知道如何配置iptables - 不要知道 - 使用google不要google - 使用这个:
iptables -I INPUT 4 -p tcp --dport 80 -j ACCEPT

(if u know how to configure iptables - do it. Dont know - use google. Dont want google - use this: iptables -I INPUT 4 -p tcp --dport 80 -j ACCEPT)