Welcome! Log In Create A New Profile

Advanced

Re: Mechanism to avoid restarting nginx upon every change

Lucas Rolff
April 09, 2017 10:00AM
Hi Ajay,

If you generate the configuration, and issue a nginx reload – it won't cause any downtime. The master process will reread the configuration, start new workers, and gracefully shut down the old ones.
There's absolutely no downtime involved in this process.


From: nginx <nginx-bounces@nginx.org<mailto:nginx-bounces@nginx.org>> on behalf of Ajay Garg <ajaygargnsit@gmail.com<mailto:ajaygargnsit@gmail.com>>
Reply-To: "nginx@nginx.org<mailto:nginx@nginx.org>" <nginx@nginx.org<mailto:nginx@nginx.org>>
Date: Sunday, 9 April 2017 at 15.55
To: "nginx@nginx.org<mailto:nginx@nginx.org>" <nginx@nginx.org<mailto:nginx@nginx.org>>
Subject: Mechanism to avoid restarting nginx upon every change

Hi All.

We are wanting to implement a solution, wherein the user gets proxied to the appropriate local-url, depending upon the credentials.
Following architecture works like a charm (thanks a ton tofrancis@daoine.org<mailto:francis@daoine.org>, without whom I would not have been able to reach here) ::

####################################################
server {
listen 2000 ssl;

ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;

location / {
auth_basic 'Restricted';
auth_basic_user_file /etc/nginx/ssl/.htpasswd;

if ($remote_user = "user1") {
proxy_pass https://127.0.0.1:2001https://127.0.0.1:2000;
}

if ($remote_user = "user2") {
proxy_pass https://127.0.0.1:2002https://127.0.0.1:2000;
}

# and so on ....

}
}
####################################################


Things are good, except that adding any new user information requires reloading/restarting the nginx server, causing (however small) downtime.

Can this be avoided?
Can the above be implemented using some sort of database, so that the nginx itself does not have to be down, and the "remote_user <=> proxy_pass" mapping can be retrieved from a database instead?

Will be grateful for pointers.


Thanks and Regards,
Ajay
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Mechanism to avoid restarting nginx upon every change

Ajay Garg April 09, 2017 09:58AM

Re: Mechanism to avoid restarting nginx upon every change

Lucas Rolff April 09, 2017 10:00AM

Re: Mechanism to avoid restarting nginx upon every change

Ajay Garg April 09, 2017 10:26AM

Re: Mechanism to avoid restarting nginx upon every change

B.R. via nginx April 10, 2017 03:36AM

Re: Mechanism to avoid restarting nginx upon every change

alexsamad April 10, 2017 05:32PM

Re: Mechanism to avoid restarting nginx upon every change

B.R. via nginx April 11, 2017 07:18AM

Re: Mechanism to avoid restarting nginx upon every change

Ajay Garg April 12, 2017 12:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 291
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready