Re: redirecting web requests from localhost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Miguel González wrote:
>     However, the Java application running in the server tries to access
> some local web content. I have changed the hosts file and some
> applications (ping, wget) they get the local IP address. However
> nslookup and maybe our Java application (I didn´t have the programmer
> available to debug it) are getting the production server IP.
>
>     So, how can I redirect for instance 443 traffic to a specific IP to
> the local IP address of the local server? I have tried this:
>
>      iptables -t nat -A PREROUTING -d XXX.XXX.XXX.XXX -p tcp --dport 80
> -j DNAT --to YYY.YYY.YYY.YYY
>
>    XXX.XXX.XXX.XXX - IP of production server
>
>    YYY.YYY.YYY.YYY - local IP of the test server


I'm not sure how to manage this on the test server, but
I'm pretty sure this would work on the prod server.

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp --dport 443 -s YYY.YYY.YYY.YYY \
-m conntrack --ctstate NEW -j DNAT --to YYY.YYY.YYY.YYY:443
iptables -t nat -A PREROUTING -m conntrack --ctstate \
ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

c


_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos





[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux