Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Nginx侦听非端口80_Linux_Amazon Web Services_Nginx - Fatal编程技术网

Linux Nginx侦听非端口80

Linux Nginx侦听非端口80,linux,amazon-web-services,nginx,Linux,Amazon Web Services,Nginx,我在NGINX上读过很多问题,其中没有监听端口80,但我的问题不同。NGINX侦听我的默认端口80,但当我尝试更改侦听81时,NGINX将侦听来自端口81的任何请求,它不会给我任何响应 不管怎样,我就是这么做的。 1.)我在/etc/nginx/sites available/myportconfig中创建了一个配置文件 2.)然后我创建了一个符号链接,如so ln-s/etc/nginx/sites available/myportconfig/etch/nginx/sites enable/

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

不管怎样,我就是这么做的。 1.)我在/etc/nginx/sites available/myportconfig中创建了一个配置文件 2.)然后我创建了一个符号链接,如so 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 -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的一个实例。但我发现谭宏达的想法是类似的解决问题的方法。我发现,除了端口80和443的请求外,所有来自服务器外部的访问都被阻止。再次感谢各位的回复–Madzmar Ullang

您是否在AWS安全组中添加了端口81的规则?在哪里提到NGINX位于AWS上?如果我没有提到它是AWS的一个实例,请原谅。但我发现谭宏达的想法是类似的解决问题的方法。我发现,除了端口80和443的请求外,所有来自服务器外部的访问都被阻止。再次感谢各位的回复