Commit fb2fbae4 authored by ale's avatar ale

Parameterize top-level domain redirects

parent 3bc8eeb7
Pipeline #4090 passed with stage
in 4 minutes and 50 seconds
......@@ -42,3 +42,12 @@ In order to support integration with custom automation mechanisms,
nginx will also load virtualhost configs from the
*/etc/nginx/sites-auto* directory (along with the standard
*sites-enabled* directory).
# Configurable parameters
`nginx_top_level_domain_redirects` - a dictionary of {domain: target}
tuples used for redirecting top-level domains to specific destinations
(DNS must be managed manually).
# Define a map with domain-level redirects.
map $http_host $top_level_domain_redirect {
default "";
{% for domain, dest in nginx_top_level_domain_redirects|default({})|dictsort %}
{{ domain }} {{ dest }};
{% endfor %}
}
server {
listen [::]:80 default_server ipv6only=off;
server_name _;
......@@ -12,6 +22,10 @@ server {
}
{% endif %}
if ($top_level_domain_redirect) {
return 301 $top_level_domain_redirect$request_uri;
}
# Redirect everything else to HTTPS.
location / {
return 301 https://$host$request_uri;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment