故事是我在配置一个OCServ服务器,然后为了安全,当然要走个HTTP Proxy,否则分享出去被人用来下BT就会有麻烦了。
然后,HTTP Proxy配置是正常的,通过
wget www.google.com -e use_proxy=yes -e http_proxy=http://127.0.0.1:3128
访问没问题
VPN服务器也是正常的,可以正常连接和访问。
但是一旦加上下面这句,80端口就超时无法打开了,同时Nginx(HTTP Proxy)日志里没有提到有访问记录(可能根本没链接到嘛),其他端口倒是仍然正常(当然
iptables -t nat -A PREROUTING -s 192.168.251.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128
然后我改成
iptables -t nat -A PREROUTING -i vpns+ -p tcp --dport 80 -j REDIRECT --to-port 3128
也不行。
整个配置在这里:
#!/bin/bash
# iptables
iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport (SSH端口,不给你看) -j ACCEPT
# ocserv
iptables -t filter -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -t filter -A INPUT -p udp -m udp --dport 443 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -d 192.168.251.0/24 -j DROP
iptables -t filter -A FORWARD -d 192.168.251.0/24 -j ACCEPT
iptables -t nat -A PREROUTING -s 192.168.251.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128 (就是这神秘的一句
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp --dport 3128 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p udp --dport 53 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp --dport 53 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp --dport 21 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp --dport 80 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp --dport 443 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp --dport 993 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp --dport 465 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.251.0/24 -p tcp -j REJECT --reject-with tcp-reset
iptables -t filter -A FORWARD -s 192.168.251.0/24 -j DROP
iptables -t nat -A POSTROUTING -s 192.168.251.0/24 -j MASQUERADE
/opt/ocserv/sbin/ocserv -c /opt/ocserv/etc/config
求解,感谢!
(俺好菜啊,怎么办)