users@glassfish.java.net

Re: How to redirect to another port

From: <glassfish_at_javadesktop.org>
Date: Fri, 15 Oct 2010 22:16:30 PDT

Sathyan, Shing Wai, Hassan, hwellmann;

I did get it working!

To take care of the port issue I used iptables as you suggested to redirect from port 80 to 38080. I used the the following;

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

Then, I noticed that the iptables rules got lost upon a server restart. To have iptables rules automatically loaded every time your networking comes up on your Debian or Ubuntu server I used the following;

iptables-save > /etc/firewall.conf

open or create /etc/network/if-up.d/iptables and place the following into it;
#!/bin/sh
iptables-restore < /etc/firewall.conf

make it executable:
chmod +x /etc/network/if-up.d/iptables

Now, the rules will be restored each time your networking scripts start (or restart). If you need to save changes to your rules in the future, you can manually edit /etc/firewall.conf or you can adjust your rules live and run:

To fix the context root issue I discovered that I could use the GlassFish Admin console and setup a virtual server to mask the WAR Name in the URL.

I also discovered I could set the domain names that the virtual server would listen on in the hosts field which provided me the additional benefit of being able to host multiple applications with a single IP address with multiple internet domain names.

You can use the Default Web Module option in the Virtual Server configuration to hide the WAR name (I other words, the context root) from the URL used for accessing your web pages. The following procedure enables your website users to type in http://www.mywebsite.com and be redirected or forwarded to http://www.mywebsite.com/hello.

Specifying the default WAR in the virtual server configuration eliminates the need to enter the war name in the URL.

Thank you all.
[Message sent by forum member 'maxmcbyte']

http://forums.java.net/jive/thread.jspa?messageID=485332