0

I need to setup dynamic redirections. For example, a user open a link : http://www.example.com/2/3/4/ and see the page on the following address: http://www.example2.pl/something.

I know about RewriteMap, but I need something which don't require nginx to restart, that is fast, simple, and is easy to use with sftp (without a database in the server).

My idea is to push files with URLs inside and configure nginx to use this file content - it is nice to me, because I can easily do it via sftp.

How can I manage to achieve this in nginx ?

My second idea is to return this file to the user and use javascript redirection. I prefer the first solution so please tell me how to read the requested file content and redirect to URLs inside.

Maybe there are some other solutions, like DNS, please tell me what will be the best.

Xavier Lucas
  • 13,095
  • 2
  • 44
  • 50
Thomas
  • 3
  • 1

1 Answers1

0

What you could do is uploading configuration files including location directives to a specific directory. That directory would be included (ie through include yourDir/*.conf) in your server configuration.

You will need to issue a signal to nginx master to reload the configuration though. @MichaelHampton is right about the fact you do no need to restart the server. Reloading the server configuration without downtime can be done by issuing the service nginx reload command or kill -SIGHUP <nginx master process ID>.

There is no 'persistent directory watch + reload on filesystem change' feature in nginx. You will need to script it (ie with Lua), but that is not recommended anyway. You could create a cron task for regularly reloading nginx configuration... looks also dirty if you ask me.

Bernard Rosset
  • 1,373
  • 12
  • 25
  • ok. it is great that i can reload config without restart nginx. I will try this solution with rewrite map - it will be better to maintanace than js script redirection. – Thomas Dec 14 '14 at 09:30