summaryrefslogtreecommitdiff
path: root/data/templates/https
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-04-10 19:42:07 +0200
committerChristian Poessinger <christian@poessinger.com>2022-04-10 19:42:07 +0200
commit77bbf766e8023e73df1c3c1360f607a4d94727fd (patch)
tree20e8967f49d64dbcd594e9db2ebd69349f29f36d /data/templates/https
parentde407ab8971d544b4a662bdeabd76c50c29b02d9 (diff)
downloadvyos-1x-77bbf766e8023e73df1c3c1360f607a4d94727fd.tar.gz
vyos-1x-77bbf766e8023e73df1c3c1360f607a4d94727fd.zip
https: T4333: migrate to new vyos_defined Jinja2 test
Diffstat (limited to 'data/templates/https')
-rw-r--r--data/templates/https/nginx.default.tmpl34
-rw-r--r--data/templates/https/override.conf.tmpl2
-rw-r--r--data/templates/https/vyos-http-api.service.tmpl4
3 files changed, 18 insertions, 22 deletions
diff --git a/data/templates/https/nginx.default.tmpl b/data/templates/https/nginx.default.tmpl
index a51505270..73ab88aae 100644
--- a/data/templates/https/nginx.default.tmpl
+++ b/data/templates/https/nginx.default.tmpl
@@ -4,56 +4,52 @@
{% for server in server_block_list %}
server {
-
# SSL configuration
#
-{% if server.address == '*' %}
+{% if server.address is vyos_defined('*') %}
listen {{ server.port }} ssl;
listen [::]:{{ server.port }} ssl;
-{% else %}
+{% else %}
listen {{ server.address | bracketize_ipv6 }}:{{ server.port }} ssl;
-{% endif %}
+{% endif %}
-{% for name in server.name %}
+{% for name in server.name %}
server_name {{ name }};
-{% endfor %}
+{% endfor %}
-{% if server.certbot %}
+{% if server.certbot is vyos_defined %}
ssl_certificate {{ server.certbot_dir }}/live/{{ server.certbot_domain_dir }}/fullchain.pem;
ssl_certificate_key {{ server.certbot_dir }}/live/{{ server.certbot_domain_dir }}/privkey.pem;
include {{ server.certbot_dir }}/options-ssl-nginx.conf;
ssl_dhparam {{ server.certbot_dir }}/ssl-dhparams.pem;
-{% elif server.vyos_cert %}
+{% elif server.vyos_cert is vyos_defined %}
ssl_certificate {{ server.vyos_cert.crt }};
ssl_certificate_key {{ server.vyos_cert.key }};
-{% else %}
+{% else %}
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
include snippets/snakeoil.conf;
-{% endif %}
+{% endif %}
ssl_protocols TLSv1.2 TLSv1.3;
# proxy settings for HTTP API, if enabled; 503, if not
location ~ /(retrieve|configure|config-file|image|generate|show|docs|openapi.json|redoc|graphql) {
-{% if server.api %}
-{% if server.api.socket %}
+{% if server.api is vyos_defined %}
+{% if server.api.socket is vyos_defined %}
proxy_pass http://unix:/run/api.sock;
-{% else %}
+{% else %}
proxy_pass http://localhost:{{ server.api.port }};
-{% endif %}
+{% endif %}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 600;
proxy_buffering off;
-{% else %}
+{% else %}
return 503;
-{% endif %}
+{% endif %}
}
-
error_page 497 =301 https://$host:{{ server.port }}$request_uri;
-
}
-
{% endfor %}
diff --git a/data/templates/https/override.conf.tmpl b/data/templates/https/override.conf.tmpl
index 824b1ba3b..1760a5ff3 100644
--- a/data/templates/https/override.conf.tmpl
+++ b/data/templates/https/override.conf.tmpl
@@ -1,4 +1,4 @@
-{% set vrf_command = 'ip vrf exec ' + vrf + ' ' if vrf is defined else '' %}
+{% set vrf_command = 'ip vrf exec ' ~ vrf ~ ' ' if vrf is vyos_defined else '' %}
[Unit]
StartLimitIntervalSec=0
After=vyos-router.service
diff --git a/data/templates/https/vyos-http-api.service.tmpl b/data/templates/https/vyos-http-api.service.tmpl
index 15bd80d65..fb424e06c 100644
--- a/data/templates/https/vyos-http-api.service.tmpl
+++ b/data/templates/https/vyos-http-api.service.tmpl
@@ -1,11 +1,11 @@
-{% set vrf_command = 'ip vrf exec ' + vrf + ' ' if vrf is defined else '' %}
+{% set vrf_command = 'ip vrf exec ' ~ vrf ~ ' ' if vrf is vyos_defined else '' %}
[Unit]
Description=VyOS HTTP API service
After=vyos-router.service
Requires=vyos-router.service
[Service]
-ExecStart={{vrf_command}}/usr/libexec/vyos/services/vyos-http-api-server
+ExecStart={{ vrf_command }}/usr/libexec/vyos/services/vyos-http-api-server
Type=idle
SyslogIdentifier=vyos-http-api