
瑞安,感谢您为我指明了正确的方向。我用一些代码充实了您的答案(第二段),它可以工作。在这种情况下,这些代码段被放入我的快速应用程序中:
// set up plain http servervar http = express.createServer();// set up a route to redirect http to httpshttp.get('*', function(req, res) { res.redirect('https://' + req.headers.host + req.url); // Or, if you don't want to automatically detect the domain name from the request header, you can hard pre it: // res.redirect('https://example.com' + req.url);})// have it listen on 8080http.listen(8080);https express服务器在3000上侦听ATM。我设置了这些iptables规则,因此节点不必以root身份运行:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 3000
总之,这完全符合我的期望。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)