You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by Martin Harris <ma...@cloudsoftcorp.com> on 2016/06/21 12:37:39 UTC

NGINX Configuration & Documentation

Hi Folks,

We've been making some additions to the Brooklyn documentation [here](
https://github.com/apache/brooklyn-docs/pull/78) and [here](
https://github.com/apache/brooklyn-docs/pull/79), and as part of it I was
attempting to setup an nginx controller to act as a reverse proxy to a HA
Brooklyn cluster

The idea is pretty simple:

[image: Inline images 1]

The nginx serves as a single front-end to the HA cluster and directs all
traffic to the Brooklyn master server. The Brooklyn master and slave server
share a single shared persisted state (standard HA configuration using S3
or NFS)

On the event of a failure of the master node, the slave node would promote
itself to master, and the nginx controller would now direct all traffic to
the slave server. If the original master were to be restarted, it would
restart as a slave and would be available in the event of failure of the
new master server

Unfortunately, I've been unable to configure nginx to do what we need. I've
got as far as [this configuration file](
https://gist.github.com/nakomis/b216e877bcea206a3c5ad782c195df9c), but in
this configuration, once it has failed over to the slave, it's not possible
to restart the master server as the new slave

If I remove the max_fails and backup directives on lines 7 & 8 in the
config above, nginx simply performs a round-robin across the two nodes

Is there a way to configure nginx to fail over from the master to the slave
(or preferably find the new master)?

Any help would be appreciated

Cheers

M


-- 
Martin Harris
Lead Software Engineer
Cloudsoft Corporation Ltd
www.cloudsoftcorp.com

Re: NGINX Configuration & Documentation

Posted by Richard Downer <ri...@apache.org>.
Hi Martin,

This mailing list strips attachments off mails, so your attached diagram
didn't reach the list. Could you post a link to it instead?

Thanks
Richard.


On 21 June 2016 at 13:37, Martin Harris <ma...@cloudsoftcorp.com>
wrote:

> Hi Folks,
>
> We've been making some additions to the Brooklyn documentation [here](
> https://github.com/apache/brooklyn-docs/pull/78) and [here](
> https://github.com/apache/brooklyn-docs/pull/79), and as part of it I was
> attempting to setup an nginx controller to act as a reverse proxy to a HA
> Brooklyn cluster
>
> The idea is pretty simple:
>
> [image: Inline images 1]
>
> The nginx serves as a single front-end to the HA cluster and directs all
> traffic to the Brooklyn master server. The Brooklyn master and slave server
> share a single shared persisted state (standard HA configuration using S3
> or NFS)
>
> On the event of a failure of the master node, the slave node would promote
> itself to master, and the nginx controller would now direct all traffic to
> the slave server. If the original master were to be restarted, it would
> restart as a slave and would be available in the event of failure of the
> new master server
>
> Unfortunately, I've been unable to configure nginx to do what we need.
> I've got as far as [this configuration file](
> https://gist.github.com/nakomis/b216e877bcea206a3c5ad782c195df9c), but in
> this configuration, once it has failed over to the slave, it's not possible
> to restart the master server as the new slave
>
> If I remove the max_fails and backup directives on lines 7 & 8 in the
> config above, nginx simply performs a round-robin across the two nodes
>
> Is there a way to configure nginx to fail over from the master to the
> slave (or preferably find the new master)?
>
> Any help would be appreciated
>
> Cheers
>
> M
>
>
> --
> Martin Harris
> Lead Software Engineer
> Cloudsoft Corporation Ltd
> www.cloudsoftcorp.com
>
>

Re: NGINX Configuration & Documentation

Posted by Yavor Yanchev <ya...@yanchev.com>.
Hi,

try_files works only for local files.

Real HA setup for nginx is only achievable when using it in combination with keepalived[1] on premise.
Keepalived uses VRRP protocol which can problematic in most of the cloud providers (especially AWS).
Nginx recommends Amazon Elastic Load Balancing[2]. There are some load-balancing features only available
in the commercial alternative.

There is a new alternative based on Corosync and Pacemaker [3], but I haven't personally tested it.
It is mentioned in Nginx's docs (page 15) when Amazon ELB can not be used [4]

Regards,
Yavor

[1] http://www.keepalived.org/ [2] 
https://www.nginx.com/products/high-availability/ [3] 
https://www.digitalocean.com/community/tutorials/how-to-create-a-high-availability-setup-with-corosync-pacemaker-and-floating-ips-on-ubuntu-14-04 
[4] 
http://d0.awsstatic.com/whitepapers/AWS_NGINX_Plus-whitepaper-final_v4.pdf
On 06/22/2016 10:39 AM, Thomas Bouron wrote:
> Hi Martin
>
> Did you try the try_files directive:
> http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files ?
> Sounds like it does what you want.
>
> Cheers
>
> On Tue, 21 Jun 2016, 13:37 Martin Harris, <ma...@cloudsoftcorp.com>
> wrote:
>
>> Hi Folks,
>>
>> We've been making some additions to the Brooklyn documentation [here](
>> https://github.com/apache/brooklyn-docs/pull/78) and [here](
>> https://github.com/apache/brooklyn-docs/pull/79), and as part of it I was
>> attempting to setup an nginx controller to act as a reverse proxy to a HA
>> Brooklyn cluster
>>
>> The idea is pretty simple:
>>
>> [image: Inline images 1]
>>
>> The nginx serves as a single front-end to the HA cluster and directs all
>> traffic to the Brooklyn master server. The Brooklyn master and slave server
>> share a single shared persisted state (standard HA configuration using S3
>> or NFS)
>>
>> On the event of a failure of the master node, the slave node would promote
>> itself to master, and the nginx controller would now direct all traffic to
>> the slave server. If the original master were to be restarted, it would
>> restart as a slave and would be available in the event of failure of the
>> new master server
>>
>> Unfortunately, I've been unable to configure nginx to do what we need.
>> I've got as far as [this configuration file](
>> https://gist.github.com/nakomis/b216e877bcea206a3c5ad782c195df9c), but in
>> this configuration, once it has failed over to the slave, it's not possible
>> to restart the master server as the new slave
>>
>> If I remove the max_fails and backup directives on lines 7 & 8 in the
>> config above, nginx simply performs a round-robin across the two nodes
>>
>> Is there a way to configure nginx to fail over from the master to the
>> slave (or preferably find the new master)?
>>
>> Any help would be appreciated
>>
>> Cheers
>>
>> M
>>
>>
>> --
>> Martin Harris
>> Lead Software Engineer
>> Cloudsoft Corporation Ltd
>> www.cloudsoftcorp.com
>>
>> --
> Thomas Bouron \u2022 Software Engineer @ Cloudsoft Corporation \u2022
> http://www.cloudsoftcorp.com/
> Github: https://github.com/tbouron
> Twitter: https://twitter.com/eltibouron
>


Re: NGINX Configuration & Documentation

Posted by Thomas Bouron <th...@cloudsoftcorp.com>.
Hi Martin

Did you try the try_files directive:
http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files ?
Sounds like it does what you want.

Cheers

On Tue, 21 Jun 2016, 13:37 Martin Harris, <ma...@cloudsoftcorp.com>
wrote:

> Hi Folks,
>
> We've been making some additions to the Brooklyn documentation [here](
> https://github.com/apache/brooklyn-docs/pull/78) and [here](
> https://github.com/apache/brooklyn-docs/pull/79), and as part of it I was
> attempting to setup an nginx controller to act as a reverse proxy to a HA
> Brooklyn cluster
>
> The idea is pretty simple:
>
> [image: Inline images 1]
>
> The nginx serves as a single front-end to the HA cluster and directs all
> traffic to the Brooklyn master server. The Brooklyn master and slave server
> share a single shared persisted state (standard HA configuration using S3
> or NFS)
>
> On the event of a failure of the master node, the slave node would promote
> itself to master, and the nginx controller would now direct all traffic to
> the slave server. If the original master were to be restarted, it would
> restart as a slave and would be available in the event of failure of the
> new master server
>
> Unfortunately, I've been unable to configure nginx to do what we need.
> I've got as far as [this configuration file](
> https://gist.github.com/nakomis/b216e877bcea206a3c5ad782c195df9c), but in
> this configuration, once it has failed over to the slave, it's not possible
> to restart the master server as the new slave
>
> If I remove the max_fails and backup directives on lines 7 & 8 in the
> config above, nginx simply performs a round-robin across the two nodes
>
> Is there a way to configure nginx to fail over from the master to the
> slave (or preferably find the new master)?
>
> Any help would be appreciated
>
> Cheers
>
> M
>
>
> --
> Martin Harris
> Lead Software Engineer
> Cloudsoft Corporation Ltd
> www.cloudsoftcorp.com
>
> --

Thomas Bouron • Software Engineer @ Cloudsoft Corporation •
http://www.cloudsoftcorp.com/
Github: https://github.com/tbouron
Twitter: https://twitter.com/eltibouron