简体   繁体   English

将端口从80和443转发到8080

[英]Forward Port from 80 & 443 to 8080

I tried to forward port 80 & 443 to 8080 on a server that I am working on https://www.neptos.io 我尝试将端口80和443转发到我正在使用https://www.neptos.io的服务器上的8080

My Angular Universal app is running on 8080 but my default angular app is running on port 80 & 443 (https) 我的Angular Universal应用程序在8080上运行,但我的默认angular应用程序在端口80和443(https)上运行

I forwarded both port 80 and 443 to 8080 via iptables using: 我使用以下命令通过iptables将端口80和443转发到8080:

iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 8080

Now when I ssh into the remote machine and run curl localhost, I get the desired result which is the angular universal app but when I open, it in a browser https://www.neptos.io I get the default angular app. 现在,当我使用SSH进入远程计算机并运行curl localhost时,会得到所需的结果,即Angle通用应用程序,但是当我打开它时,在浏览器https://www.neptos.io中将其获取默认的angular应用程序。

Am i doing something wrong here? 我在这里做错什么了吗?

Any help would be appreciated. 任何帮助,将不胜感激。

I believe the OUTPUT chain will only effect traffic generated on the localhost. 我相信OUTPUT链只会影响在本地主机上生成的流量。 To redirect incoming traffic you need to use the PREROUTING chain. 要重定向传入流量,您需要使用PREROUTING链。

 iptables -t nat -I PREROUTING --src 0/0 --dst 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 8080 

Just replace the localhost ip with what ever your interface IP is 只需用您的接口IP替换localhost ip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 axios 试图连接端口 80 而不是 8080? - Why is axios trying to connect on port 80 and not 8080? 使用NGINX将端口80转发到8080 - Forwarding port 80 to 8080 using NGINX 如何在Windows Azure中将公用端口80连接到VM端口8080 - How to connect public port 80 to VM port 8080 in windows azure 无法在端口80或443上运行node.js Web服务 - cannot run node.js webservice on port 80 or 443 在443端口上使用SSL运行节点应用(在80上正在运行) - Run node app with SSL on 443 port (on 80 is working) 测试客户端是否可以使用端口80,443,843连接到WebSockets - Testing if client can connect to WebSockets with port 80, 443, 843 端口8080或80上的移动网络中的WebSocket连接失败 - WebSocket connection failed in mobile network on port 8080 or 80 将SSL(PORT 443)添加到Nginx反向代理服务器(PORT 80)-Nginx配置文件 - Adding an SSL (PORT 443) to an Nginx Reverse Proxy Server (PORT 80) - Nginx Config File 如何创建http将端口80上的http请求重定向到端口443上的https? - How do create an http redirect an http request coming in on port 80 to https on port 443? 简单地从本地主机:80到本地主机:8080的nginx反向代理不起作用 - Simply nginx reverse proxy from localhost:80 to localhost:8080 not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM