Skip to content

Updating-drupal-common-drupal-fallback-optional #2348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roles/debian/nginx/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ 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"
# drupal_fallback: []
# 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;']
Expand Down
5 changes: 5 additions & 0 deletions roles/debian/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
set_fact:
nginx_location_behavior: "{{ nginx.custom_nginx_location_behavior | default(['try_files @rewrite /index.php?$query_string;']) }}"

- name: Set drupal fallback location if defined
set_fact:
drupal_fallback_behavior: "{{ nginx.drupal_fallback }}"
when: nginx.drupal_fallback is defined and nginx.drupal_fallback

- name: Copy project type-specific configuration in place.
ansible.builtin.template:
src: "{{ item }}.j2"
Expand Down
7 changes: 7 additions & 0 deletions roles/debian/nginx/templates/drupal_common.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ location / {
{{ nginx_location_behavior | join("\n ") }}
}

# Fallback to Drupal PHP handler
{% if nginx.drupal_fallback is defined %}
location @drupal {
{{ nginx.drupal_fallback | join("\n ") }}
}
{% endif %}

############ Blacklist block.
# Most of those should not be in the webroot in the first place,
# but we still provide a safety net.
Expand Down
Loading