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 set up the wiki software Gitit to run on two separate ports of the same Apache server (ports 1848 and 4000). I've confirmed that they are running.

Now I want to proxy these two sites to prettier URLs, like sitea.com and siteb.com. The IP address for both is the same (say, 12.34.56.78).

My server admin has added DNS entries for the names, but I can't seem to get my Apache configuration to work. Following the instructions here, I tried to set up a VirtualHost like this:

NameVirtualHost *:1848

<VirtualHost *:1848>
    ServerName sitea.com
    DocumentRoot /var/www/
    RewriteEngine On
    ProxyPreserveHost On
    ProxyRequests Off

    <Proxy *>
       Order deny,allow
       Allow from all
    </Proxy>

    ProxyPassReverse /    http://127.0.0.1:1848
    RewriteRule ^(.*) http://127.0.0.1:1848$1 [P]

    ErrorLog /var/log/apache2/error.log
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

</VirtualHost>

And another similar virtual host for the other on port 4000. But when I then issue service httpd restart, I get a FAILED message when starting httpd, and my browser can't connect to sitea.com.

As far as I know, the rest of my httpd.conf is the default file that comes with the distribution. My server is being run on a RedHat Enterprise machine. I'm a newbie to Apache, so I'm sure there's an obvious answer here, but after trying various tweaks to the config, I can't figure out what I'm doing wrong.

EDITED: The problem was that I didn't check to make sure the pathnames to my error logs was correct. My distribution stores logs in /var/log/httpd not /var/log/apache2. (Blushes.)

share|improve this question
    
Which version of apache you are using ? –  GeekRide Dec 22 '12 at 8:41
    
Also, can you paste the error which you are getting here, the one on the display as well as in the error logs. That will help us understand about the problem in better way. –  GeekRide Dec 22 '12 at 8:47
    
Checking the error logs (which I should have thought to do myself) helped me figure out the problem. See my edit in the original post. –  Caleb McDaniel Dec 22 '12 at 15:43

2 Answers 2

up vote 0 down vote accepted
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

This example is from apache documentation for virutal hosts. Define your reverse proxy settings in each <VirtualHost/> block.

config below might be helpful

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName sitea.com
    DocumentRoot /var/www/
    RewriteEngine On
    ProxyPreserveHost On
    ProxyRequests Off

    <Proxy *>
       Order deny,allow
       Allow from all
    </Proxy>

    ProxyPass        /    http://127.0.0.1:1848/
    ProxyPassReverse /    http://127.0.0.1:1848/

    ErrorLog /var/log/apache2/error.log
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On
</VirtualHost>

<VirtualHost *:80>
    ServerName siteb.com
    DocumentRoot /var/www/
    RewriteEngine On
    ProxyPreserveHost On
    ProxyRequests Off

    <Proxy *>
       Order deny,allow
       Allow from all
    </Proxy>

    ProxyPass        /    http://127.0.0.1:4000/
    ProxyPassReverse /    http://127.0.0.1:4000/

    ErrorLog /var/log/apache2/error.log
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On
</VirtualHost>
share|improve this answer
    
This answer doesn't give any solution to the problem. It simply explain how to configure VirtualHosts, which are already done by Caleb. –  GeekRide Dec 22 '12 at 8:49
    
my answer should point int right direction. –  rhasti Dec 22 '12 at 9:36
    
This answer was still helpful. I'm embarrassed to admit what the problem was, but see my edited OP ... –  Caleb McDaniel Dec 22 '12 at 15:40
    
Now this answer is does makes sense. Thanx –  GeekRide Dec 22 '12 at 16:14

Embarrassed to say this, but the problem was that the path to my error logs was wrong. My distribution puts the error logs in /var/log/httpd, so Apache was choking every time it got to the ErrorLog line because no such directory existed. Live and learn ...

share|improve this answer

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.