重定向导致的奇怪错误
请军哥帮忙看看!LNMP1.3安装完,添加虚拟主机,工作正常,IP访问或未添加的地址都指向LNMP那个默认页面。需要把某个二级域名转发到81端口上的另一个服务,因此在/usr/local/nginx/conf/vhost下添加一个conf文件,内容为:
server
{
listen 80;
server_name test.xxx.com;
rewrite ^(.*) http://test.xxx.com:81/$1 permanent;
}
重启LNMP之后,包括这个二级域名、以前配置了别的虚拟主机的域名或者IP,所有的都无法访问,ERR_CONNECTION_REFUSED。
删除这个配置文件,重启LNMP,依旧。
用lnmp vhost add添加一个test.xxx.com,依旧。
自此所有对这台主机80端口的访问全部ERR_CONNECTION_REFUSED。
这是为什么呢? 如果用 scheme 來轉呢?
[ 本帖最后由 scorpioliu 于 2016-3-18 12:36 编辑 ] /usr/local/nginx/sbin/nginx -t 测试配置
netstat -ntl 查看端口
iptables -L -n 确认规则 正常时是这样
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:54399 0.0.0.0:* LISTEN
tcp6 0 0 :::51907 :::* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::25 :::* LISTEN
iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all--0.0.0.0/0 0.0.0.0/0
ACCEPT all--0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp--0.0.0.0/0 0.0.0.0/0 tcp dpt:22
ACCEPT tcp--0.0.0.0/0 0.0.0.0/0 tcp dpt:80
DROP tcp--0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
ACCEPT icmp --0.0.0.0/0 0.0.0.0/0 icmptype 8
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
异常时这样:
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:54399 0.0.0.0:* LISTEN
tcp6 0 0 :::51907 :::* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::25 :::* LISTEN
iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all--0.0.0.0/0 0.0.0.0/0
ACCEPT all--0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp--0.0.0.0/0 0.0.0.0/0 tcp dpt:22
ACCEPT tcp--0.0.0.0/0 0.0.0.0/0 tcp dpt:80
DROP tcp--0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
ACCEPT icmp --0.0.0.0/0 0.0.0.0/0 icmptype 8
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
异常时少一行
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
80端口上没有监听 发现lnmp restart时,出现一个错误:
Stoping nginx... nginx: invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
但是查看这个"/usr/local/nginx/logs/nginx.pid"文件为空
[ 本帖最后由 zorange 于 2016-3-18 13:46 编辑 ] 发现reboot后,80上的服务正常了,但是设置了转发的test.xxx.com并没有被转发到81。
lnmp restart后,80上再次没有服务。
再次重启,报错
Stoping LNMP...
Stoping nginx... nginx: open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
failed. Use force-quit
[ ok ] Stopping mariadb (via systemctl): mariadb.service.
Gracefully shutting down php-fpm . done
Starting LNMP...
Starting nginx... nginx (pid 3568 3567 3469) already running.
[ ok ] Starting mariadb (via systemctl): mariadb.service.
Starting php-fpmdone 我发现问题的根本原因了,不是端口转发的问题,是重启lnmp时nginx没起来。
Starting nginx... nginx (pid 3568 3567 3469) already running.
我81端口上跑的也是个nginx,这个重启时发现已有一个,就没启动。
但为什么reboot后就能同时启两个呢? 好吧,我为什么非要跑两个nginx呢,用一个吧……
页:
[1]