Skip to content

Commit

Permalink
Use http2 and http3 nginx directives (#1529)
Browse files Browse the repository at this point in the history
* Use `http2` directive in nginx wordpress site template.
Add `http2_enabled` configuration.

* Use `http3` directive in nginx wordpress site template.
Add `http3_enabled` configuration.

* Prefix `http2_enabled` and `http3_enabled` options with `nginx_`.
  • Loading branch information
strarsis authored Jul 23, 2024
1 parent fbd8b41 commit ab4226b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions roles/wordpress-setup/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ nginx_sites_confs:
- src: ssl.no-default.conf.j2
enabled: false

nginx_http2_enabled: true
nginx_http3_enabled: false

# HSTS defaults
nginx_hsts_max_age: 31536000
nginx_hsts_include_subdomains: false
Expand Down
12 changes: 8 additions & 4 deletions roles/wordpress-setup/templates/wordpress-site.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

server {
{% block server_id -%}
listen {{ ssl_enabled | ternary('[::]:443 ssl http2', '[::]:80') }};
listen {{ ssl_enabled | ternary('443 ssl http2', '80') }};
listen {{ ssl_enabled | ternary('[::]:443 ssl', '[::]:80') }};
listen {{ ssl_enabled | ternary('443 ssl', '80') }};
http2 {{ nginx_http2_enabled | default(false) | ternary('on', 'off') }};
http3 {{ nginx_http3_enabled | default(false) | ternary('on', 'off') }};
server_name {{ site_hosts_canonical | union(multisite_subdomains_wildcards) | join(' ') }};
{% endblock %}

Expand Down Expand Up @@ -290,11 +292,13 @@ server {
{% for host in item.value.site_hosts if host.redirects | default([]) %}
server {
{% if ssl_enabled -%}
listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:443 ssl;
listen 443 ssl;
{% endif -%}
listen [::]:80;
listen 80;
http2 {{ nginx_http2_enabled | default(false) | ternary('on', 'off') }};
http3 {{ nginx_http3_enabled | default(false) | ternary('on', 'off') }};
server_name {{ host.redirects | join(' ') }};

{{ self.https() -}}
Expand Down

0 comments on commit ab4226b

Please sign in to comment.