Welcome! Log In Create A New Profile

Advanced

rewrite by script

Posted by UKenGB 
rewrite by script
May 28, 2021 09:40AM
I need to rewrite/redirect a number of simple URLs to more complex ones and those destination URLs are stored in files and can be accessed by any (e.g. bash) script. Indeed I use a CGI script that accesses and uses those URLs for audio streaming. Although I could enter these URLs into nginx's rewrite rules to accomplish what I need, I don't want to have to duplicate them as that just complicates things and makes keeping them updated more error prone.

The only way to do this that I can think of is to direct requests to a CGI that CAN read the required files and redirect appropriately.

However, what I really want to do is create nginx rewrite rules that access these script files in order to create the destination URLs to which the requests are redirected. Is this possible? Can rewrite rules utilise other files in this way?



Edited 1 time(s). Last edit at 05/28/2021 09:43AM by UKenGB.
Re: rewrite by script
May 28, 2021 10:10AM
Not possible with stock nginx but you can with Lua (openresty), here we use it to map any.dom.com where 'any' has aliases stored in a cached database which gets refreshed daily.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: rewrite by script
May 28, 2021 12:21PM
Thanks for confirming that. I thought it might be the case.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready