【发布时间】:2017-03-13 18:22:44
【问题描述】:
我在 NGINX 上阅读了许多问题,其中它不监听端口 80,但我的问题不同。 NGINX 监听我的默认端口 80,但是当我尝试更改监听 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 时,网站加载正常。但是当我更改为不同的端口时,它不会加载任何页面......我错过了什么吗?请帮忙...
我也试过用
做 netstatnetstat -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安全组81端口的规则添加了吗?
-
哪里提到 NGINX 位于 AWS 上?
-
对不起,如果我没有提到它是 AWS 的一个实例。但我发现 Tan Hong Tat 的想法有点类似解决问题的方法。我发现除了 80 和 443 端口的请求外,所有来自服务器外部的访问都被阻止了。再次感谢大家的回复
标签: linux amazon-web-services nginx