转发传出stream量到不同的端口

我的linux中的应用程序连接到“ip.example.com”。

“ip.example.com”的IP地址在/ etc / hosts中定义为

10.23.22.1 ip.example.com 

在目标IP上,服务正在端口8080上运行。但是,应用程序正试图连接10.23.22.1:80 ,并且失败。 无法修改目标IP或在本地运行的应用程序。

我想在我的本地邮箱转发从10.23.11.1:8010.23.22.1:8080的传出stream量。

这是可能在ip表中实现?

是的,可以使用如下规则:

 iptables -t nat -A OUTPUT -p tcp --dport 80 -d 10.23.11.1 -j DNAT --to-destination :8080 

如果这不是一个使用iptables的原则,我会build议使用nginx(或另一个web服务器)和代理path模块:

 location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto https; proxy_redirect off; proxy_connect_timeout 9999h; proxy_send_timeout 240; proxy_read_timeout 9999h; proxy_pass http://10.23.22.1:8080; }