Opened 7 years ago

#1360 new enhancement

enhancement: auto-reload map includes

Reported by: jessicah@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.13.x
Keywords: Cc:
uname -a: Linux f6f149766778 3.12.57-44-default #1 SMP Wed Apr 6 09:18:15 UTC 2016 (9b4534f) x86_64 Linux
nginx -V: nginx version: nginx/1.13.3
built by gcc 6.2.1 20160822 (Alpine 6.2.1)
built with OpenSSL 1.0.2k 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module

Description

When using an include file with the map directive, it would be ideal if nginx automatically reloaded its configuration when the include file is modified.

Use-case: currently I use the map functionality to rewrite a 'current' URL for downloads to the latest version as produced by buildbot. As nginx is running in a docker container, there isn't any way to reload the nginx configuration without root privileges (at least that I'm aware of).

E.g. buildbot runs a script to generate currentImages.map.nginx:

/nightly-images/x86_64/current-anyboot /nightly-images/x86_64/haiku-nightly-hrev51366-x86_64-anyboot.zip;

If instead, I use a symlink in /nightly-images/x86_64, ln -s haiku-nightly-hrev51366-x86_64-anyboot.zip current-anyboot, then when downloading the file using the current link, the downloaded file has the name of the symlink, rather than the target.

My configuration is along the lines of:

http {
  map $uri $new {
    include /haiku-files/nightly-images/currentImages.map.nginx;
  }
  server {
    if ($new) {
      return 302 $new;
    }
  }
}

With Apache2 and RewriteMap, it automatically reloads the map configuration when the include file is modified. I can't see any way to achieve the same with nginx, which will hamper moving away from Apache2.

Change History (0)

Note: See TracTickets for help on using tickets.