用nginx代理的loopback接口正确设置PF

我试图运行我的web服务器和应用程序服务器,这是运行node.js freebsd监狱几个

我有一个网卡( igb0 )与自定义的回送接口( lo666 ),我已经创build了3个别名,这里是我的/etc/rc.conf

 dumpdev="AUTO" zfs_enable="YES" sshd_enable="YES" local_unbound_enable=yes ifconfig_igb0="inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255" # Custom loopback interface cloned_interfaces="lo666" ifconfig_lo666_alias0="inet 10.6.6.6 netmask 255.255.255.255" ifconfig_lo666_alias1="inet 10.6.6.7 netmask 255.255.255.255" ifconfig_lo666_alias2="inet 10.6.6.8 netmask 255.255.255.255" # Default router defaultrouter="192.168.1.254" 

在我的/etc/pf.conf我有这个

 ### Interfaces ### ExtIf ="igb0" IntIf ="lo666" ### Hosts ### IP_PUB ="192.168.1.1" IP_JAIL = "{10.6.6.6, 10.6.6.7, 10.6.6.8}" IP_JAIL_WWW = "10.6.6.6" IP_JAIL_DBS = "10.6.6.7" IP_JAIL_APP = "10.6.6.8" NET_JAIL="10.6.6.0/24" ### Ports ### PORT_WWW="{80,443}" PORT_NODE="{1337,8080}" scrub in all # nat all jail traffic nat pass on $ExtIf from $NET_JAIL to any -> $IP_PUB # WWW rdr pass on $ExtIf proto tcp from any to $IP_PUB port $PORT_WWW -> $IP_JAIL_WWW rdr pass on $IntIf proto tcp from any to $IP_JAIL_WWW port $PORT_NODE -> $IP_JAIL_APP 

如此运行

 # pfctl -sn nat pass on igb0 inet from 10.6.6.0/24 to any -> 192.168.1.1 rdr pass on igb0 inet proto tcp from any to 192.168.1.1 port = http -> 10.6.6.6 rdr pass on igb0 inet proto tcp from any to 192.168.1.1 port = https -> 10.6.6.6 rdr pass on lo666 inet proto tcp from any to 10.6.6.6 port = 1337 -> 10.6.6.8 rdr pass on lo666 inet proto tcp from any to 10.6.6.6 port = 8080 -> 10.6.6.8 

所以从WWW​​监狱我可以

 root@www:/ # curl http://10.6.6.8:1337 Hello World 

也从APP监狱我可以看到nginx的主页

 root@app:/# curl http://10.6.6.6 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> ... </html> 

所以,为什么我得到一个502错误的网关,当我尝试通过浏览器访问这个错误? 这里是我的nginx.conf

 server { server_name web.domain.tld; location / { # For Read Requests proxy_pass http://10.6.6.8:1370; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 

这是我在我的nginx错误日志中得到的

 2014/05/23 13:14:44 [error] 92876#0: *1 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 192.168.1.10, server: web.domain.tld, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.6.6.8:1370/favicon.ico", host: "web.domain.tld" 

也许我过于复杂,我想实现的是阻止端口1337外部用户。

任何意见非常赞赏。

在nginx.conf中应该是http://10.6.6.8:1337而不是http://10.6.6.8:1370