[CentOS] redirecting web requests from localhost

Wed Aug 28 19:49:31 UTC 2013
Miguel González <miguel_3_gonzalez at yahoo.es>

Dear all,

    I´m testing a server and try to simulate a server in production. We 
have a SSL certificate and I have configured the test server with the 
same servername as it is in production. To access it, I change the hosts 
file in my laptop to reach the test server.

    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

   Thanks

   Miguel




This message and any attachments are intended for the use of the addressee or addressees only. The unauthorised disclosure, use, dissemination or copying (either in whole or in part) of its content is not permitted. If you received this message in error, please notify the sender and delete it from your system. Emails can be altered and their integrity cannot be guaranteed by the sender.

Please consider the environment before printing this email.