@jeffjade
2017-07-13T16:01:15.000000Z
字数 1575
阅读 1403
Nginx
POST http://nicelinks.site/api/auth/login net::ERR_CONNECTION_RESET
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to [::]:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to [::]:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to [::]:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to [::]:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: bind() to [::]:80 failed (98: Address already in use)
2017/07/03 16:02:48 [emerg] 29168#29168: still could not bind()
查看当前80端口的转发规则,使用命令
iptables -t nat -L -n | grep 80
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 4000
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 80
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 80
这里也可以使用规则号码(外加参数 --line-numbers):
iptables -t nat -L -n --line-numbers | grep 80
1 REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 4000
2 REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 80
所以如果你想删除第二条规则,你可以做像这样:
iptables -D INPUT 2
如果您使用特定的表(例如nat),则必须将其添加到delete命令中:
sudo iptables -t nat -D PREROUTING 1
如此,能够很好的实现从iptables中删除特定的规则,感谢来自 How can I remove specific rules from iptables? 有效的回答。