37 lines
752 B
Django/Jinja
37 lines
752 B
Django/Jinja
# {{ ansible_managed }}
|
|
|
|
{% for dname in nginx.redirect_dnames %}
|
|
{% for site in nginx.reverseproxy_sites %}
|
|
{% set from = site.from | regex_replace('auro.re', dname) %}
|
|
{% set to = site.from %}
|
|
{% if from != site.from %}
|
|
# Redirect http://{{ from }} to http://{{ to }}
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
|
|
server_name {{ from }};
|
|
|
|
location / {
|
|
return 302 http://{{ to }}$request_uri;
|
|
}
|
|
}
|
|
|
|
# Redirect https://{{ from }} to https://{{ to }}
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
|
|
server_name {{ from }};
|
|
|
|
# SSL common conf
|
|
include "/etc/nginx/snippets/options-ssl.conf";
|
|
|
|
location / {
|
|
return 302 https://{{ to }}$request_uri;
|
|
}
|
|
}
|
|
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|