Nginx听不到端口80

时间:2014-12-16 04:23:31

标签: linux amazon-web-services nginx

我在NGINX上已经阅读了很多问题,其中不听端口80,但我的问题不同。 NGINX监听我的默认端口80,但当我尝试更改Listen 81时,NGINX将收听来自端口81的任何请求,它不会给我任何响应。

无论如何,这就是我的所作所为。 1.)我在/ etc / nginx / sites-available / myportconfig中创建了一个配置文件 2.)然后我创建了一个符号链接,如ln -s / etc / nginx / sites-available / myportconfig / etch / nginx / sites-enable / 3.)我没有修改/etc/nginx/nginx.conf中的任何内容 4.)最后,这是myportconfig的内容

    server {                
        listen 81;
        root /mysites/sites1.com;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name 10.100.100.10;

        if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$)
        {
                rewrite ^(.*)$ / permanent;
        }
        # remove trailing "index" from all controllers
        if ($request_uri ~* index/?$)
        {
                rewrite ^/(.*)/index/?$ /$1 permanent;
        }


        if (!-d $request_filename)
        {
                rewrite ^/(.*)/index/?$ /$1 permanent;
        }

        if ($request_uri ~* ^/system)
        {
                rewrite ^/(.*)$ /index.php?/$1 last;
                break;
        }

        if (!-e $request_filename)
        {
                rewrite ^/(.*)$ /index.php?/$1 last;
                break;
        }
        location / {
                try_files $uri $uri/ =404;
        }

        error_page 404 /404.html;

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_buffers 16 16k;
                fastcgi_buffer_size 32k;
                fastcgi_param SCRIPT_FILENAME /mysites/sites1.com$fastcgi_script_name;
                include fastcgi_params;
        }

        location ~ /\.ht {
                deny all;
        }

        # Restrict .git directories
        location ~ /\.git {
                deny all;
        }

        # Restrict all project directories
        location ~ /\. {
                deny all;
        }
}

另请注意,当仅使用端口80时,网站加载得很好。当我换到不同的端口然后它没有加载任何页面...我是否错过了一些人?请帮忙......

我也试过用

做netstat
netstat -lnp | grep 8

它给了我这个输出

   tcp   0   0.0.0.0:81        0.0.0.0:*       LISTEN
   udp   0   0.0.0.0:68        0.0.0.0:*

我也试过在服务器内做telnet

   telnet 10.100.100.10 81

以及响应

    Trying 10.100.100.10
connected to 10.100.100.10
Escape character is '^]'.
Connection closed by foreign host.

当我在本地计算机上telnet

    telnet 10.100.100.10 81
Connecting To 10.100.100.10....Could not open connection to the host, on port 81:
Connection failed

希望someonne可以帮助我。我想要做的是使用不同的端口访问我的网站,而不是使用端口80

1 个答案:

答案 0 :(得分:0)

很抱歉,如果我没有提到它是AWS的一个实例。但我发现谭洪达的想法有点类似于解决问题的方法。我发现除了端口80和443的请求之外,所有来自服务器外部的访问都被阻止了。再次感谢回复人员 - Madzmar Ullang