首页 文章

Node Express应用程序重定向端口443在hostmonster上请求端口3000

提问于
浏览
0

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

我希望请求端口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 的请求,并且它不会从我的主节点快速应用程序页面返回信息,而是在端口3000上进行侦听 .

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

我错过了什么?

1 回答

  • 0

    我不确定你添加的规则是否正确 .

    Jenkins example on forwarding with iptables建议您尝试以下方法:

    iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 3000
    

相关问题