Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have two web applications that run on the same server. Each require a different port number, but only one port is open to the public. My company would rather avoid opening another port up but still wants both to be apps public, so I'm trying to figure out how to have both run. I know a little about apache, but I'm confused on how to set it up to do this. Should I use a reverse proxy or is there another way to accomplish my goal?

share|improve this question
    
You said: "Each require a different port number". So do you care if an URL looks like http://example.com:81/ ? –  Lekensteyn Dec 15 '10 at 15:13
    
Can you have two different DNS names to point to your public IP? If so, you can host them on the same apache server without the need to change the port. Each app will reside in a different vhost / different path. –  Khaled Dec 15 '10 at 15:18
    
@Lekensteyn they can look like example.com:81 and it will be fine. –  evilrobotz Dec 15 '10 at 15:22
    
@Khaled That may be a possibility. We only have one domain, but do you think that a subdomain (ie: pub.example.com) will work? If not then we might purchase a second domain. –  evilrobotz Dec 15 '10 at 15:25

1 Answer 1

You can use apache virtual hosts. Look at this page. You can use another subdomain for the other app. No need to purchase a new domain. Also, you don't need to change the port number. For example, you can use:

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/app1
ServerName app1.example.com

# Other directives here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/app2
ServerName app2.example.com

# Other directives here

</VirtualHost> 

In this example, the app1 will reside in /var/www/app1 and app2 will reside in /var/www/app2

share|improve this answer
    
Thanks I'll give this a shot. –  evilrobotz Dec 15 '10 at 15:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.