我的 Ngxin 运行得很好。但现在我想将我的网站更改为另一个端口。我尝试过我的 Drupal 网站和我的基本 php 脚本网站。两者都不起作用。
我的虚拟主机很简单。
server
{
listen 81;
server_name wiki.domain.com;
index index.php index.html index.htm;
root /opt/www/domain_wiki;
error_page 404 = @drupal;
location @drupal {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
access_log logs/domain_wiki.log main;
}
我所做的只是将 80 改为 81。
我尝试测试了端口。看起来一切正常。
# nc -z localhost 81
Connection to localhost 81 port [tcp/hosts2-ns] succeeded!
我重新启动,重新加载,-t Nginx。一切正常。
有想法吗?
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:http
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTAB LISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:f tp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:s sh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:h ttps
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:h ttp
REJECT all -- anywhere anywhere reject-with icmp-ho st-prohibited
答案1
确保 iptables 规则也允许流量通过 TCP/81 进入您的机器。
例如:
允许任何人的流量进入
iptables -I INPUT -p tcp --dport 81 -j ACCEPT
答案2
您有防火墙吗?您有其他程序监听 81 端口吗?您运行 SELinux 了吗?
nginx 中没有任何东西会导致这样的问题,所以您正在寻找操作系统级别的某些东西。