linux - Nginx 监听而不是端口 80

标签 linux amazon-web-services nginx

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

无论如何,这就是我所做的。 1.) 我在/etc/nginx/sites-available/myportconfig 中创建一个配置文件 2.)然后我创建了一个符号链接(symbolic link),如下所示 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

希望有人能帮助我解决这个问题。我想做的是使用不同的端口而不是使用端口 80 访问我的网站

最佳答案

抱歉,如果我没有提到它是 AWS 的一个实例。但我发现 Tan Hong Tat 的想法与这个问题的解决方案有点类似。我发现除了端口 80 和 443 的请求之外,所有来自服务器外部的访问都被阻止。再次感谢大家的回复 – Madzmar Ullang

关于linux - Nginx 监听而不是端口 80,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27497481/

相关文章:

amazon-web-services - AWS CloudFormation 错误 : [Value of property {/Tags/0/Values} does not match type {Map}]

nginx - Nginx worker_rlimit_nofile

linux - vim:在 block 的开头插入不起作用

amazon-web-services - 无法在 Cognito 托管 UI 中确认注册用户

amazon-web-services - CloudFormation 模板无效 : Template format error: Every Outputs member must contain a Value object

web-services - Nginx SSL 直通不适用于 REST Web 服务

asynchronous - 如果它不存在,如何让nginx重试静态文件

linux - 以其他用户身份运行 X Apps 时无法打开显示

mysql - 如何在没有弹性 IP 地址的弹性负载均衡器后面通过 ssh 和 sftp 进入 ec2

linux - 用于从 shell 启动的命令的标准输入/标准输出