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

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

 



Thanks for the replies. Fortunately I was able to get everything
working to an acceptable level. But it seems I'm running a very
minimal configuration and there's definitely room to improve. First,
to answer some of you questions about the app itself, the users log in
at home.example.com, which pulls elements from home and shared. Once
they log in, they can select there training course to begin their
studies, which then takes them to training.example.com. So I have all
those vhosts set up on the proxy and the exact same vhosts set up on
the back end servers. So the proxy will send all requests exactly how
they are to server 1. If server 1 ever fails, it then starts sending
all requests to server 2. Here's what I did to get it working.


I added a Balancer with this configuration. I also made a second one for HTTPS.
NameVirtualHost 192.168.2.210:80
<Proxy balancer://balancer1>
BalancerMember http://192.168.2.211/ route=1 redirect=2
BalancerMember http://192.168.2.212/ route=2 status=+H
</Proxy>

### Then, I set up four different vhosts for home, training, and
shared. home has one for http and https. On the backend server, any
requests to home.example.com get redirected to HTTPS.
<VirtualHost 192.168.2.210:80>
ServerName home.example.com
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On

        ProxyPass / balancer://balancer1/
        ProxyPassReverse / balancer://balancer1/

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

### The fix that solved most of my problems was the ProxyPass and
ProxyPassReverse directive. All the examples I had been looking at
were using domain names here (because they weren't really load
balancing) so this is where I was really struggling conceptually to
figure out how it's suppose to work. I then found out that you can put
your balancer, which I did, and everything started working.

So I configured it and tested it out and it seems to work rather well.
I can reboot server one and my requests instantly start going to
server 2. Even though it's working, I still have a few more questions
I'd like to ask, if that's alright.

1. I found that once server 1 came back online, it started receiving
all the requests again. Is there a way to keep that server in an error
state until I'm ready to have it start serving again? Is this what the
"retry" value is for? Do I just have to set it to a really high
number?

2. I also found that once a failover occurs, users are logged out
because their session doesn't exist on the hot spare. Sessions are
handled by a cookie with PHPSESSID. I saw that there is a
"stickysession" option. Will this allow the session to be maintained
across the two servers? If not, is there a way to do this? (Forgive my
ignorance on this part, but I'm just a systems guy and
cookies/sessions is a little beyond my knowledge area).

3. To make sure I'm understanding the BalancerMember config
correctly... "route=1" means to always use this member first, right?
And "redirect=2" means that if that member is unavailable, to always
use the member with route=2? And status=+H means to keep this member
inactive until all other members are in an error state, correct?

4. Now that I have it working with the above configuration, and
considering I'm a mod_proxy newbie, are there any other settings I
should be aware of? Any advice or suggestions you have?

Thanks.



On Fri, Mar 15, 2013 at 7:39 AM, Daniel Ruggeri <DRuggeri@xxxxxxxxxxx> wrote:
> On 3/14/2013 11:15 AM, Ryan Merrell wrote:
>> 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.
> Yes, absolutely.
>
>> 2) If it is doable, what config changes do I need to make so it uses
>> the hostname instead of the default vhost?
> See question below - we can diagnose this with more info.
>
>> 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?
> I'm just verifying but do you mean an active/passive backend? If so,
> that is trival to accomplish but you will need to use the balancer.
>
>
> Your configuration example looks good. The most important directive is
> the ProxyPreserveHost. Is there any way on the backend server to log the
> host header received? It sounds like the backend has a name-based vhost
> setup and my initial suspicion is that we're losing something on the way
> there. Another helpful module in httpd is mod_dumpio which will show the
> request as sent to the backend (but produces tons of logs).
>
> Feel free to review/steal examples from this presentation as we get
> closer to the balancer config:
> http://people.apache.org/~druggeri/notes/ApacheConNA%202010%20Presentation.odp
>
> --
> Daniel Ruggeri
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>

---------------------------------------------------------------------
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