1

我有一个安全(https)节点快速应用程序,我在端口 3000 => https://mywebsite.net:3000上运行hostmonster

我希望对端口 443 的请求(即https://mywebsite.net / https://mywebsite.net:443)转发到我的节点快速服务器应用程序侦听端口 3000 => https://mywebsite.net:3000

这是因为无法直接监听 443 端口。

我以 root 身份登录到hostmonster 。

我在 iptable 中添加了以下规则:

iptables -t nat -A PREROUTING -s 123.123.123.123 -p tcp --dport 443 -j DNAT --to-destination 
service iptables save

我在输入时看到以下内容:iptables -t nat -L

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  server.mywebsite  anywhere tcp dpt:https to: 123.123.123.123:3000
DNAT       tcp  --  server.mywebsite  anywhere tcp dpt:https to: 123.123.123.123:3000

问题是如果我在浏览器中键入https://mywebsite.nethttps://mywebsite.net:443(同样的事情),它不会转到我的主节点快速应用程序页面监听端口 3000。 

我还使用 Google 的邮递员发出了https://mywebsite.net:443的请求,但它没有从我的主节点 express 应用程序页面返回侦听端口 3000 的信息。

所以从端口 443 到端口 3000 的重定向似乎没有工作?

我错过了什么?

4

1 回答 1

1

我不确定您添加的规则是否正确。

Jenkins 关于使用 iptables 转发的示例建议您应该尝试以下操作:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 3000
于 2016-12-19T16:55:54.333 回答