summaryrefslogtreecommitdiff
path: root/roles/nginx/vhost
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2023-10-09 22:19:57 +0200
committerChristian Pointner <equinox@spreadspace.org>2023-10-09 22:19:57 +0200
commitee2555abe7767818295bd04334e5d6b6c3de5a0d (patch)
tree81904d68c70f77f75ae05faa37cc613df0e39437 /roles/nginx/vhost
parentnginx/vhost: refactor templates and add tlsonly variant (diff)
nginx/vhost: make listen addresses configurable
Diffstat (limited to 'roles/nginx/vhost')
-rw-r--r--roles/nginx/vhost/templates/generic.conf.j214
-rw-r--r--roles/nginx/vhost/templates/tlsonly.conf.j27
2 files changed, 12 insertions, 9 deletions
diff --git a/roles/nginx/vhost/templates/generic.conf.j2 b/roles/nginx/vhost/templates/generic.conf.j2
index 97cb8269..cdf267ab 100644
--- a/roles/nginx/vhost/templates/generic.conf.j2
+++ b/roles/nginx/vhost/templates/generic.conf.j2
@@ -1,7 +1,8 @@
server {
- listen 80{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
- listen [::]:80{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
- server_name {{ nginx_vhost.hostnames | join(' ') }};
+{% for listen in (nginx_vhost.listen | default(['80', '[::]:80'])) %}
+ listen {{ listen }}{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
+{% endfor %}
+ server_name {{ nginx_vhost.hostnames | default(['_']) | join(' ') }};
{% if 'logs' in nginx_vhost %}
{% if 'access' in nginx_vhost.logs %}
@@ -23,9 +24,10 @@ server {
}
server {
- listen 443 ssl http2{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
- listen [::]:443 ssl http2{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
- server_name {{ nginx_vhost.hostnames | join(' ') }};
+{% for listen in (nginx_vhost.tls.listen | default(['443', '[::]:443'])) %}
+ listen {{ listen }} ssl http2{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
+{% endfor %}
+ server_name {{ nginx_vhost.hostnames | default(['_']) | join(' ') }};
{% if 'logs' in nginx_vhost %}
{% if 'access' in nginx_vhost.logs %}
diff --git a/roles/nginx/vhost/templates/tlsonly.conf.j2 b/roles/nginx/vhost/templates/tlsonly.conf.j2
index 2af0e7ad..122e2f4f 100644
--- a/roles/nginx/vhost/templates/tlsonly.conf.j2
+++ b/roles/nginx/vhost/templates/tlsonly.conf.j2
@@ -1,7 +1,8 @@
server {
- listen {{ nginx_vhost.tls.port | default(443) }} ssl http2{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
- listen [::]:{{ nginx_vhost.tls.port | default(443) }} ssl http2{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
- server_name {{ nginx_vhost.hostnames | join(' ') }};
+{% for listen in (nginx_vhost.tls.listen | default(['443', '[::]:443'])) %}
+ listen {{ listen }} ssl http2{% if 'default' in nginx_vhost and nginx_vhost.default %} default_server{% endif %};
+{% endfor %}
+ server_name {{ nginx_vhost.hostnames | default(['_']) | join(' ') }};
{% if 'logs' in nginx_vhost %}
{% if 'access' in nginx_vhost.logs %}