views:

38

answers:

1

Hello everyone,

I am working with a web development framework which publish its applications in apache server ports:8080, 8081, 8082, etc.

For instance MyApp1 runs in localhost:8080, MyApp2 runs in localhost:8081, and so on.

What I would like to achieve is that my domains point to a "port" where its application is running in my apache web server, e.g. www.mydomainclient1.com should point to 8080 port and www.mydomainclient2.com should point to 8081 port.

What I have done is I have entered to my Domain Name Provider web site, then went to Total DNS Control and point these domains to my dedicated server IP.

Now, my domains point to mydedicatedserverIP, so when I do www.mydomainclient1.com and www.mydomainclient2.com they both access mydedicatedserverIP, by default 80 port.

The situation I am trying to solve is:

I'd like to have www.mydomainclient1.com pointing directly to mydedicatedserverIP:8080 and www.mydomainclient2.com pointing to mydedicatedserverIP:8081.

What do you think would be a good solution for this? (I hope my question is clear enough due I am not a native english speaker as you can see)

Environment: Linux Debian 5 Lenny, Apache Server 2.2.9-10+lenny8

As I am a newbie in apache server any comment or suggestion will be very appreciated, even if you think is something obvious :-).

Thank you very much for your time and help.

Carlos Balderas

+2  A: 

To make sure I understand what you meant: You want -

  • Client issues HTTP request to http://mydomain1.com (port 80) - then go to port 8080 on your server;
  • Client issues HTTP request to http://mydomain2.com (port 80) - then go to port 8081 on your server.

The only reasonable way (that I know of) you can achieve this in Apache is by using what's called a Reverse Proxy, explained here: http://httpd.apache.org/docs/current/mod/mod_proxy.html

In a nutshell: Define two name-based virtual hosts listening on port 80, each reverse-proxying requests to the "hidden" server. The two definitions would be almost exactly the same.... here's a sketch of one of them, you should be able to conclude the other one.

<NameVirtualHost *:80>
    ServerName mydomain1.com
    ServerAlias www.domain1.com
    ... *other aliases as you wish* ...
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
</NameVirtualHost>

The above definition causes all HTTP requests coming in on port 80, having "mydomain1.com" in their "Server path" header (that's standard behavior when someone types in a URL containing a server name; don't worry about it) or any of the mentioned aliases, to be reverse-proxied to "localhost:8080".

Try this and let us know how it went. Good luck!

Isaac

Isaac
Isaac, thank you very much for your answer, about your question the answer is yes, you understood right =). I did what you told me and I got the redirection I was looking for. As I said before I have no experience working with web servers but I'd like to make a second part of this question, to make some remarks about this topic (in case someone is following it), but I need to make some tests first. I try to end this by the end of this week. Thanks again, It was a great help for me!!
Carlos Balderas