Welcome! Log In Create A New Profile

Advanced

RewriteMap without reload configuration on NGINX

RewriteMap without reload configuration on NGINX
August 30, 2022 07:53AM
Hi guys,

I want to configure 301 and 302 redirections on NGINX like we can do in Apache using RewriteMap. Per instance (Apache configuration)

```
RewriteEngine On
RewriteMap redirects txt:/opt/maps.txt
RewriteCond ${redirects:%{HTTP_HOST}%{REQUEST_URI}} ^.+$
RewriteRule .* http://${redirects:%{HTTP_HOST}%{REQUEST_URI}} [R=301,QSA,NE,L]
```
In this configuration, any change over /opt/maps.txt doesnt need any reload / restart

I tried to make the analog configuration in NGINX with map directive. Something like

```
map $request_uri $new_uri_301 {
include /etc/nginx/snippets/rewritemap.conf;
}
location / {
if ($new_uri_301) {
return 301 $new_uri_301;
}
}
```
The thing is that every change in /etc/nginx/snippets/rewritemap.conf require make a reload. Can we avoid that? There is a way to dynamically reload the configuration like in Apache?

King regards guys
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 262
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready