Re: Struggling with Reverse Proxy Configuration for Server with multiple subdomains

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






On Fri, Mar 15, 2013 at 3:15 AM, Ryan Merrell <ryanmerrell@xxxxxxxxx> wrote:
Our web application (an LMS) uses three subdomains to serve its content:

home.example.com
training.example.com
shared.example.com

These are all vhosts running off of 1 server. My end goal is to use
mod_proxy as a reverse proxy and to load balance between two servers.
Until we can make changes to the app to be more tolerant to HA
systems, the load balancer will most likely need to be Active/Passive
between two back end servers.

I'm new to mod_proxy, so I've started off with just trying to set up a
1:1 reverse proxy, meaning one proxy server sending all traffic to one
server only. But I can't seem to get that working. Every example I can
find for setting up a reverse proxy uses examples like
"example.com/$FUNCTION" as the public side and "$FUNCTION.example.com'
as the private.

Correct.
 
For example, www.example.com/shared on the proxy goes
to shared.example.com on the private side. www.example.com/training on
the proxy goes to training.example.com on the private side. I can't do
this without considerable changes to how our application works. What i
need is for home.example.com on the proxy to go to home.example.com on
the back end. Same for shared and training.

On the proxy I tried configuring 3 vhosts (home.example.com,
shared.example.com, and training.example.com). An example is like the
following:(proxy is 192.168.2.210 and host 1 is 192.168.2.211)

NameVirtualHost 192.168.2.210:80
<VirtualHost 192.168.2.210:80>
ServerName home.example.com
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On

ProxyPass / http://192.168.2.211/
ProxyPassReverse / http://192.168.2.211/

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

</IfModule>
</VirtualHost>

I have the same thing for training and shared as well. Then on the
backend server, I have a standard vhost configuration for the three
vhosts (meaning if I change my dns to resolve to 192.168.2.211, the
web page functions as expected).

When you go to http://192.168.2.211/, how do you access each of the applications? Meaning what is the direct url you will be using? In your current set-up there isn't any right? So how are you going to distinguish to which backend application you are going to send a specific request?


With this set up, and my DNS resolving to the proxy for all three
subdomains, I can pull up the few items that loads from "home", but
anything being requested from shared (training isn't used on the login
screen) gets a 404. When I look at the backend server looks, the 404
is looking in home's document root instead of Shared. So it seems that
all requests being passed to the back end server are going to the
default vhost and not based off of the Host name.Everything I can find
regarding this type of error have lead to making sure the
NameVirtualHost and VirtualHost directives match, which they do and it
still seems to go to the first vhost listed.

So a couple questions I have are
1) Is what I'm planning to accomplish even doable? I figured if it was
I'd at least be able to find just one example out on the Internet, but
I haven't been able to, which has created doubt as to whether I'm
fully understanding how mod_proxy works.
2) If it is doable, what config changes do I need to make so it uses
the hostname instead of the default vhost?
3) If I can get this part to work, am I going to have any problems in
getting an Active/Passive load balancer set up?

You need to host the domains on the frontend apache and forward the requests to the backend application, but you can't host it on both frontend and backend as you are doing. Example:

NameVirtualHost 192.168.2.210:80
<VirtualHost 192.168.2.210:80>
ServerName home.example.com
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On

ProxyPass / http://192.168.2.211/home/
ProxyPassReverse / http://192.168.2.211/home/

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

</IfModule>
</VirtualHost>

Then on the backend server you'll have:

NameVirtualHost 192.168.2.211:80
<VirtualHost 192.168.2.211:80>
    ServerName <call_it_whatever_you_want>
    DocumentRoot <your_document_root>/home/
</VirtualHost>
<VirtualHost 192.168.2.211:80>
    ServerName <call_it_whatever_you_want>
    DocumentRoot <your_document_root>/training/
</VirtualHost>
<VirtualHost 192.168.2.211:80>
    ServerName <call_it_whatever_you_want>
    DocumentRoot <your_document_root>/shared/
</VirtualHost>

and put the home application files under <your_document_root>/home/, where <your_document_root> for most of the linux's would be /var/www.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux