Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have a lot of Vhost on my server, and I'm looking for a way to easily configure Url rewriting without having to open Putty, connect on SSH and editing with vim.

Is it possible to put the rewrite rules in a file in my www folder and to reload Nginx conf every 5-10 minutes ?

I don't want a htaccess-like behavior. Just to put all the rewrinting rules in my project's folder (for SVN).

Thanks in advance (and sorry for my english) !

share|improve this question
up vote 0 down vote accepted

Nginx configuration files have an include directive, so you could do something like this in the configuration file where your rewrite rules currently reside:

include /srv/http/path/to/somefile.nginx;

Next configure a cronjob as root to do an /etc/init.d/nginx reload - or whichever way your init scripts reload nginx configs - every 15 minutes or every hour or so.

If your only grief with having config files where they're supposed to be is having to edit them with vim, you could also use sshfs on linux or winscp on windows to log in via SFTP or SCP and edit config files in /etc with your favourite GUI editor.

share|improve this answer
Thanks ! Can I put this configuration file in my ftp folder ? Isn't it a serious security breach ? – Tyrius Jan 15 '13 at 10:01
Is it possible to associate it with this : ? So when I edit my file, Nginx is reload immediatly. – Tyrius Jan 15 '13 at 10:07
You can certainly put this file in your FTP folder. It may or may not be a security concern if you do any sensitive processing in there - or if other users have access to your FTP folder. Assuming no other users have access to your FTP folder, you'll be fine, but you might want to block access to that file - for example with something like a location /somefile.nginx { deny all; } directive. And using incrond instead of a normal cron should work fine, too - it's still just a regular file ;). – Magnus Jan 15 '13 at 13:16
Okay, thank you so much for all this explanations. It'll be fine for me ! – Tyrius Jan 15 '13 at 16:35

You can use include to include another file as part of your configuration, meaning you could put all your vhosts config in there. You can of course specify the path to the file, meaning it could be stored anywhere on your system.

share|improve this answer
Thanks for your reply. I'll try it as soon as possible ! :) – Tyrius Jan 15 '13 at 10:00

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.