LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Help with ReverseProxy on Ubuntu (http://www.linuxquestions.org/questions/linux-server-73/help-with-reverseproxy-on-ubuntu-4175428413/)

mcc28 09-21-2012 12:54 PM

Help with ReverseProxy on Ubuntu
 
Hi,

I have Ubuntu server running with Apache installed and working. I have a virtual WordPress appliance(Virtualbox) running on the server.

The server ip is 192.168.0.32 and the WordPress server is on 192.168.0.14. To reach the WordPress server I type 192.168.0.14/wordpress - using the hostname (wordpress) doesn't work and I can't ping it on the network (but I can ping 192.168.14).

The Ubuntu server hostname is thaddeus and I want to be able to type http://thaddeus/wordpress and reach the wordpress appliance running at 192.168.0.14/wordpress - I understand Proxypass/ProxypassReverse do this...

Under sites-available I have added the file wordpress:

Code:

#This is for virtual host sites on server2 @ 192.168.0.14
<VirtualHost *:80>
        ServerAdmin webmaster@domain.com
        ServerName elswhere.domain.com
# You can have list of space separated aliases if you server2 hosts multiple domains
        ServerAlias wordpress
# If you have multiple hosts (NameVirtualHosts on server 2, you will need to preserve
# hostname, or you will always land at the root of
# the second server. ie: what ever the default site is.
        ProxyPreserveHost on
# Need to allow location / if you want the proxy to
# work when no folder is written in the url.
        <location />
          allow from all
    </location>

# This is where all the magic happens.
# You can modify the following for specific folders only and any remote host
# you can also specify a different port if you like
        ProxyPass /wordpress http://192.168.0.14/
        ProxyPassReverse /wordpress http://192.168.0.14/

</VirtualHost>
~

and enabled the site & restarted Apache. It doesn't work though - the Apache error log says /var/www/wordpress does not exist.

Could anyone help please?

thanks

Mark

acid_kewpie 09-21-2012 01:16 PM

Code:

        ServerName elswhere.domain.com
        ServerAlias wordpress

one of these needs to be "thaddeus" or the virtualhost will not match.

also you have illogical config on the ProxyPass. If you map "/wordpress" to "http://1.2.3.4/" then "http://thaddeus/wordpress" will be converted to "http://1.2.3.4/", not "http://1.2.3.4/wordpress". Also you need to match the slashes there, as otherwise "http://thaddeus/wordpress/something/else" will map to "http://1.2.3.4//something/else" which would usually actually work but is clearly messy and can lead to other mess, esp on the ProxyPassReverse side.

mcc28 09-21-2012 01:41 PM

Quote:

Originally Posted by acid_kewpie (Post 4786034)
Code:

        ServerName elswhere.domain.com
        ServerAlias wordpress

one of these needs to be "thaddeus" or the virtualhost will not match.

also you have illogical config on the ProxyPass. If you map "/wordpress" to "http://1.2.3.4/" then "http://thaddeus/wordpress" will be converted to "http://1.2.3.4/", not "http://1.2.3.4/wordpress". Also you need to match the slashes there, as otherwise "http://thaddeus/wordpress/something/else" will map to "http://1.2.3.4//something/else" which would usually actually work but is clearly messy and can lead to other mess, esp on the ProxyPassReverse side.

Hi Thanks for this, I have amended the virtualhost file and it looks like this:

Code:

#This is for virtual host sites on server2 @ 192.168.0.14
<VirtualHost *:80>
        ServerAdmin webmaster@domain.com
        ServerName thaddeus
# You can have list of space separated aliases if you server2 hosts multiple domains
        ServerAlias wordpress
# If you have multiple hosts (NameVirtualHosts on server 2, you will need to preserve
# hostname, or you will always land at the root of
# the second server. ie: what ever the default site is.
        ProxyPreserveHost on
# Need to allow location / if you want the proxy to
# work when no folder is written in the url.
        <location />
          allow from all
    </location>

# This is where all the magic happens.
# You can modify the following for specific folders only and any remote host
# you can also specify a different port if you like
        ProxyPass /wordpress http://192.168.0.14/
        ProxyPassReverse /wordpress http://192.168.0.14/

</VirtualHost>
~

If I browse to thaddeus/wordpress it now works but there are some errors still. Notably some links and some content does not render correctly. Below is the apache error.log

Code:

[Fri Sep 21 19:35:14 2012] [error] [client 192.168.0.6] File does not exist: /etc/apache2/htdocs, referer: http://thaddeus/wordpress
[Fri Sep 21 19:35:14 2012] [error] [client 192.168.0.6] File does not exist: /etc/apache2/htdocs, referer: http://thaddeus/wordpress
[Fri Sep 21 19:35:26 2012] [error] [client 192.168.0.6] File does not exist: /etc/apache2/htdocs, referer: http://thaddeus/wordpress
[Fri Sep 21 19:35:39 2012] [error] [client 192.168.0.6] File does not exist: /etc/apache2/htdocs, referer: http://thaddeus/wordpress
[Fri Sep 21 19:35:39 2012] [error] [client 192.168.0.6] File does not exist: /etc/apache2/htdocs, referer: http://thaddeus/wordpress
[Fri Sep 21 19:35:39 2012] [error] [client 192.168.0.6] File does not exist: /etc/apache2/htdocs, referer: http://thaddeus/wordpress

Is this to do with the ProxyPassReverse setting?

Further help appreciated...thank you.

acid_kewpie 09-21-2012 03:01 PM

right so where is the wordpress installation relative to "/etc/apache2/htdocs"?

mcc28 09-21-2012 04:19 PM

Quote:

Originally Posted by acid_kewpie (Post 4786106)
right so where is the wordpress installation relative to "/etc/apache2/htdocs"?

Hi,

I can't really answer this! I can't find a directory htdocs under Apache2.

When I browse to thaddeus/wordpress - none of the graphics load, some of the links point to an incorrect location, for example the link to LOGIN to Wordpress points to (hovering over the link) thaddeus/wp-login.php but it should point to thaddeus/wordpress/wp-login.php - something is wring with the path but not sure what?

Wordpress is installed on /var/www/wordpress on the virtual machine (hostname - wordpress)

acid_kewpie 09-22-2012 03:08 PM

right so it's your config that's referencing /etc/apache2/htdocs... I don't think that's a default, but clearly you need to set a correct DocumentRoot for it to work.

mcc28 09-25-2012 01:44 PM

Quote:

Originally Posted by acid_kewpie (Post 4786720)
right so it's your config that's referencing /etc/apache2/htdocs... I don't think that's a default, but clearly you need to set a correct DocumentRoot for it to work.

Hi,

Been away for a few days so I will check this out and see if it resolves the issues.

thanks


All times are GMT -5. The time now is 02:56 PM.