freifunkh / ansible

Here we store all Ansible roles and configs used for Freifunk Hannover.
MIT License
7 stars 3 forks source link

web: redirect alias locations like dirs #268

Closed herbetom closed 1 month ago

herbetom commented 1 month ago

This seems like the quickest way to do this. One could probably look into wheter it's possible to teach templates/05-nginx-site-location.j2 how to figure this out on it's own or at least create some shortcut. But without the ability to test this i didn't want to try a more advanced way.

Additional Context:

Alias Locations should have a trailing slash to avoid path traversal: https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md


If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass, memcached_pass, or grpc_pass, then the special processing is performed. In response to a request with URI equal to this string, but without the trailing slash, a permanent redirect with the code 301 will be returned to the requested URI with the slash appended.

Source: https://nginx.org/en/docs/http/ngx_http_core_module.html#location

1977er commented 1 month ago

Hmpf. That burned the /download.html location. I knew I don't like permanents.

herbetom commented 1 month ago

mhm, i overlooked that case. Sorry. I think #269 probably fixes that. Maybe test it first :see_no_evil:

Permanent is the redirect tpye which is beeing used by nginx to do such redirects. Thats why i used it ...