diff --git a/roles/debian/nginx/defaults/main.yml b/roles/debian/nginx/defaults/main.yml index 56d69572d..3a73d33a3 100644 --- a/roles/debian/nginx/defaults/main.yml +++ b/roles/debian/nginx/defaults/main.yml @@ -127,6 +127,17 @@ nginx: php_fastcgi_backend: "127.0.0.1:90{{ php.version[-1] | replace('.', '') }}" # for unix socket use "unix:/var/run/php{{ php.version[-1] | replace('.','') }}-fpm.sock" ratelimitingcrawlers: false client_max_body_size: "700M" + # Default location behavior for nginx + # If no custom location behavior is defined, this will be used: + # nginx_location_behavior: ['try_files @rewrite /index.php?$query_string;'] + + # Uncomment and customize the following lines if you want to use custom location behavior: + # custom_nginx_location_behavior: + # - 'index index.php index.html;' + # - 'expires max;' + # - 'set $boost_cache_path "/cache/normal/$host";' + # - 'set $boost_cache_file "${boost_cache_path}${uri}_.html";' + # - 'try_files $boost_cache_file $uri $uri/ @drupal;' fastcgi_read_timeout: 60 recreate_vhosts: true # handle vhosts with ansible, if 'true' then clean up 'sites-enabled' dir and run domain.yml. vhost_backup_location: "/home/{{ _ce_provision_username }}" # see _init for _ce_provision_username diff --git a/roles/debian/nginx/tasks/main.yml b/roles/debian/nginx/tasks/main.yml index 74aa7942d..afe537000 100644 --- a/roles/debian/nginx/tasks/main.yml +++ b/roles/debian/nginx/tasks/main.yml @@ -150,6 +150,10 @@ - nginx.overrides is defined - nginx.overrides | length > 0 +- name: Set nginx location behavior, fallback to default if no custom behavior is provided + set_fact: + nginx_location_behavior: "{{ nginx.custom_nginx_location_behavior | default(['try_files @rewrite /index.php?$query_string;']) }}" + - name: Test NGINX configuration. ansible.builtin.command: nginx -t register: _nginx_test_result diff --git a/roles/debian/nginx/templates/drupal_common.j2 b/roles/debian/nginx/templates/drupal_common.j2 index 3e406dd6d..eb2eca4b8 100644 --- a/roles/debian/nginx/templates/drupal_common.j2 +++ b/roles/debian/nginx/templates/drupal_common.j2 @@ -19,10 +19,10 @@ location @phpprocess { # so they get processed through the app level (and 404). location / { {% if nginx.ratelimitingcrawlers %} -# @todo -# limit_req zone=bots burst=5 nodelay; + # @todo + # limit_req zone=bots burst=5 nodelay; {% endif %} - try_files @rewrite /index.php?$query_string; + {{ nginx.nginx_location_behavior | join("\n ") }} } ############ Blacklist block.