Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

want to redirect port on one host on a virtual host webserver

Status
Not open for further replies.

stevenriz

IS-IT--Management
May 21, 2001
1,069
Hi, I am not even sure this can be done. I hope so... I would like to be able to take one website on a webserver currently service 120+ websites and redirect port 80 on it to a different port where a jboss application is running. Is there a way in iptables to do this? I don't see any way to do it, but maybe you experts know of a way around it....

For instance, this server serves up...
...
I'd like to take and redirect it to
Thoughts??
Thanks!
Steve
 
Iptables? Why not do something simple like having an index.php on that goes something like this:

Code:
<?
header("location:[URL unfurl="true"]http://www.site3.com:8090");[/URL]
?>
 
Well, because (I think) they don't want the port number showing up in the address bar. I was going to try something like "pound" to do something like this as well... but I'd rather use iptables if it can do it....
 
I couldn't imagine using iptables for this, unless all 120+ sites running on the box had their own discrete IP address.

Instead of using pound, you could avoid the extra software and just use mod_proxy, no? (I'm assuming you're using Apache, here...) In any case, some sort of proxy or redirect is probably the best way to proceed here.
 
Assuming Apache is the webserver.

Couldn't you use Virtual Hosts, named or IP based. Or like jkupski mentioned, mod_proxy.

The mod_proxy option works well with tomcat, jboss or any other servlet container. I use it to "connect" users to tomcat (port 8080) without having a port number in the URL. Works great.

Just a thought, iptables may not work as expected. From my experience it works best as 1 to 1 mapping not 1 to many. And you'll probably still have port numbers in the URL. More info might help.
 
Hi and thanks, it sounds like you know what we are trying to do. Yes we are using jboss at port 8090. So this will take care of the redirect? I don't know much about mod_proxy. Do you know how I can get started in learning about this?
 
As long as you are using apache as your web server.

Here's how I got mine to work. I use it inside a <VirtualHost> directive but it should work elsewhere.

Code:
<IfModule mod_proxy.c>
    ProxyRequests On
    ProxyPass /servlet/name [URL unfurl="true"]http://<ServerName>:8080/servlet/name[/URL]
    ProxyPass /servlet/*.jsp [URL unfurl="true"]http://<ServerName>:8080/servlet/name[/URL]
    ProxyPass /*.jsp [URL unfurl="true"]http://<ServerName>:8080/servlet/name[/URL]
    ProxyPass /* [URL unfurl="true"]http://<ServerName>:8080/servlet/name[/URL]
</IfModule>

You probably don't need all the ProxyPass statements. I just included some of the combinations I've used in the past.

FYI, this will connect the servlets' dynamic content with static content (images) served by apache. In my case, if the URL has port numbers the images will not display properly, if at all.

Hope this is enough detail. [pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top