Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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 : linux.die.net/man/5/incrontab ? 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

 
discard

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.