ansible-role-nginx-config icon indicating copy to clipboard operation
ansible-role-nginx-config copied to clipboard

Nested location

Open GaetanJourdan opened this issue 2 years ago • 2 comments

Hello! I have the impression that it is not possible to have a nested location directive within a location directive. Is this a planned feature? Thanks :)

GaetanJourdan avatar Jul 06 '23 07:07 GaetanJourdan

It's not planned at this time. That being said, you should be able to define some by using the custom_directives parameter https://github.com/nginxinc/ansible-role-nginx-config/blob/main/templates/http/default.conf.j2#L427-L435 😄

alessfg avatar Jul 06 '23 11:07 alessfg

It would be nice to be able to combine things like authentication and php. The proposed way with custon_directives is working but definitely it is ugly hackish approach ;-)

...
- location: ~ /foto/
  auth_basic:
    realm: "'Please log in.'"
    user_file: $document_root/foto/.htpasswd
  custom_directives:
    - "location ~ \\.php {"
    - "    include snippets/fastcgi-php.conf;"
    - "    fastcgi_pass unix:/run/php/php-fpm.sock;"
    - "}"

gimli2 avatar Jun 19 '24 22:06 gimli2