Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want create a task on my Capistrano deploy to put my public IP on geo module configuration of my NGINX server without restart NGINX, is it possible? Example, my /etc/nginx/nginx.conf:

geo $geo {
  default no;
  include /home/deploy_user/appname/shared/ip_list;

The file /home/deploy_user/appname/shared/ip_list I will provide during deploy. I need this because my public IP can change many times.

Regards, João

share|improve this question

Since your configuration file is located in /etc/nginx I'm assuming your using some kind of Debian based flavor of Linux.

I'd basically backup and replace the ip_list at deploy time with something like this:

cd /home/deploy_user/appname/shared/ip_list
mv ip_list ip_list`date +"%Y%m%d%H%M%S"`
cp <path to new ip_list> ip_list

Then you can reload your configurations into Nginx without loosing any requests by issuing:

sudo service nginx reload or sudo /etc/init.d/nginx reload.

This will kill off any workers with the old config as they finish and start up all new workers with your new config. This way you won't loose any requests

Just make sure you can run your command with elevated privileges from Capistrano since this is necessary to reload/restart Nginx.

share|improve this answer
Yes, I use Ubuntu. In my case I don't need backup IPs but it's interesting. Nice! It works! But, I still have one problem, my application restart when nginx reload, but I think it's not pertinent of this thread. Explaining my case, my application is a Rails App using Passenger, I think will be more interesting now change to Unicorn. thanks! – joaorvmaia Nov 8 '12 at 11:57
I guess you could take a look at this gist which shows how to issue certain signals to Unicorn from Capistrano. Good luck. – deRailed Nov 8 '12 at 15:50
I will look, thks! – joaorvmaia Nov 8 '12 at 22:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.