How to Proxy one Apache server to another?

Asked by milligank on 2009-12-07

I'm trying to access a Apache Server (vle.src.ac.uk), but I want this apache server to proxy to another apache server (vle2.src.ac.uk) Can anyone help me as to why this code isnt working within the http.conf file:

<VirtualHost 172.16.4.158>
ServerName http://vle.src.ac.uk
DocumentRoot /var/www
 RewriteEngine on
 RewriteRule http://vle2.src.ac.uk/ [P]
</VirtualHost>

Many thanks guys,
Ken

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu apache2 Edit question
Assignee:
No assignee Edit question
Solved by:
Appiah
Solved:
2009-12-08
Last query:
2009-12-08
Last reply:
2009-12-07
Appiah (appiah) said : #1

You should provide error log.

Are you trying to reverse proxy?
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

If yes enable mod_proxy : sudo a2enmod proxy and read above

milligank (milligank) said : #2

Error log is this: [Sun Dec 06 07:44:30 2009] [notice] Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g configured -- resuming normal operations
[Mon Dec 07 09:05:31 2009] [notice] caught SIGWINCH, shutting down gracefully
[Mon Dec 07 09:05:34 2009] [notice] Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g configured -- resuming normal operations
[Mon Dec 07 09:11:17 2009] [error] [client 172.16.4.57] File does not exist: /var/www/favicon.ico
[Mon Dec 07 09:25:58 2009] [notice] caught SIGWINCH, shutting down gracefully
[Mon Dec 07 09:26:01 2009] [notice] Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g configured -- resuming normal operations
[Mon Dec 07 09:26:20 2009] [error] [client 172.16.4.57] File does not exist: /var/www/favicon.ico

I just want to make all requests for vle.src.ac.uk to get proxied to vle2.src.ac.uk

Thanks again, much appreciated.
Ken

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Appiah
Sent: 07 December 2009 09:45
To: Kenneth Milligan
Subject: Re: [Question #93147]: How to Proxy one Apache server to another?

Your question #93147 on Ubuntu changed:
https://answers.launchpad.net/ubuntu/+question/93147

    Status: Open => Needs information

Appiah requested for more information:
You should provide error log.

Are you trying to reverse proxy?
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

If yes enable mod_proxy : sudo a2enmod proxy and read above

--
To answer this request for more information, you can either reply to
this email or enter your reply at the following page:
https://answers.launchpad.net/ubuntu/+question/93147

You received this question notification because you are a direct
subscriber of the question.

Greater Choice - Greater Opportunities !
This email (and any attachments) is confidential and may contain
personal views which are not the views of the southern regional
college unless specifically stated. This e-mail is for the exclusive use
of the addressee/s. If you are not an addressee, then any distribution, copying
or use of this e-mail is prohibited. If you have received it in error, please
advise the sender and delete from your system.

Best Appiah (appiah) said : #3

First do in a terminal.

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
ls -al /etc/apache2/mods-enabled/ to see if mod_rewrite is enabled.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html read up on how to specify rules.

milligank (milligank) said : #4

All of these modules are already enabled, still doesn’t work?

Am I using the proper script for proxying one apache (vle.src.ac.uk) to another (vle2.src.ac.uk)?

Many thanks,
Ken

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Appiah
Sent: 07 December 2009 10:18
To: Kenneth Milligan
Subject: RE: [Question #93147]: How to Proxy one Apache server to another?

Your question #93147 on apache2 in ubuntu changed:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/93147

    Status: Open => Answered

Appiah proposed the following answer:
First do in a terminal.

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
ls -al /etc/apache2/mods-enabled/ to see if mod_rewrite is enabled.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html read up on how to
specify rules.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/93147/+confirm?answer_id=2

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/93147

You received this question notification because you are a direct
subscriber of the question.

Greater Choice - Greater Opportunities !
This email (and any attachments) is confidential and may contain
personal views which are not the views of the southern regional
college unless specifically stated. This e-mail is for the exclusive use
of the addressee/s. If you are not an addressee, then any distribution, copying
or use of this e-mail is prohibited. If you have received it in error, please
advise the sender and delete from your system.

milligank (milligank) said : #5

This solved my question:
Proxy forwarding is done by modifying the http.conf file with the info below.
You will also need the modules mod_proxy_http and mod_proxy within Mods enabled (/etc/Apache2)

# Put this after the other LoadModule directives
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

# Put this with your other VirtualHosts, or at the bottom of the file
NameVirtualHost *
<VirtualHost *>
                ServerName nameofserver.ac.uk

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

                ProxyPass / http://nameofservertoproxytoo.ac.uk/
                ProxyPassReverse / http://nameofservertoproxytoo.ac.uk/
                <Location />
                                Order allow,deny
                                Allow from all
                </Location>
</VirtualHost>

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of milligank
Sent: 07 December 2009 10:36
To: Kenneth Milligan
Subject: RE: [Question #93147]: How to Proxy one Apache server to another?

Your question #93147 on apache2 in ubuntu changed:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/93147

    Status: Answered => Open

You are still having a problem:
All of these modules are already enabled, still doesn’t work?

Am I using the proper script for proxying one apache (vle.src.ac.uk) to
another (vle2.src.ac.uk)?

Many thanks,
Ken

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Appiah
Sent: 07 December 2009 10:18
To: Kenneth Milligan
Subject: RE: [Question #93147]: How to Proxy one Apache server to another?

Your question #93147 on apache2 in ubuntu changed:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/93147

    Status: Open => Answered

Appiah proposed the following answer:
First do in a terminal.

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
ls -al /etc/apache2/mods-enabled/ to see if mod_rewrite is enabled.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html read up on how to
specify rules.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/93147/+confirm?answer_id=2

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/ubuntu/+source/apache2/+question/93147

You received this question notification because you are a direct
subscriber of the question.

Greater Choice - Greater Opportunities !
This email (and any attachments) is confidential and may contain
personal views which are not the views of the southern regional
college unless specifically stated. This e-mail is for the exclusive use
of the addressee/s. If you are not an addressee, then any distribution, copying
or use of this e-mail is prohibited. If you have received it in error, please
advise the sender and delete from your system.

You received this question notification because you are a direct
subscriber of the question.

Greater Choice - Greater Opportunities !
This email (and any attachments) is confidential and may contain
personal views which are not the views of the southern regional
college unless specifically stated. This e-mail is for the exclusive use
of the addressee/s. If you are not an addressee, then any distribution, copying
or use of this e-mail is prohibited. If you have received it in error, please
advise the sender and delete from your system.

Appiah (appiah) said : #6

You should set this as solved!

milligank (milligank) said : #7

Thanks Appiah, that solved my question.