0

I am trying to recursively serve the content of a folder for several customer IDs to pertain backwards compatibility to a respective application beyond my influence. I want all URLs paths beginning with /<integer_customer_id>/<integer_display_id>/config/<whatever...> to be serving the files /var/cache/digsig/config/<whatever...>.

This is what I've tried so far:

location ~ ^/[0-9]+/[0-9]+/config/ {
    alias /var/cache/digsig/config/;
}

Resulting in:

$ wget http://localhost:/993002/104/config/config.ini
--2016-12-07 12:08:57--  http://localhost/993002/104/config/config.ini
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/993002/104/config/config.ini/ [following]
--2016-12-07 12:08:57--  http://localhost/993002/104/config/config.ini/
Reusing existing connection to localhost:80.
HTTP request sent, awaiting response... 403 Forbidden
2016-12-07 12:08:57 ERROR 403: Forbidden.

The log says:

2016/12/07 12:08:57 [error] 8232#8232: *4 directory index of "/var/cache/digsig/config/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET /993002/104/config/config.ini/ HTTP/1.1", host: "localhost"

Why is the alias directive moved permanently and why does it get added a / at the end, destroying the actual path? Please note that I do not have any return 301 ... statements in my entire Nginx configuration.

Richard Neumann
  • 144
  • 1
  • 8
  • 1
    http://nginx.org/r/alias «If alias is used inside a location defined with a regular expression then such regular expression should contain captures and alias should refer to these captures» – Alexey Ten Dec 07 '16 at 12:48
  • What is the configuration of the complete `server` block? – Tero Kilkanen Dec 08 '16 at 14:39

0 Answers0