server {
	listen 443 default_server;

	include ssl.conf;

	location = /healthcheck {
		return 200 "I am in good health!\n";
	}

	location / {
		if ($http_x_forwarded_proto = "http") {
			return 301 https://$host:<%= Proxy.https_port %>$request_uri;
		}

		return 444;
	}
}
<% apex_domains.each do |d| %>
server {
	listen 443;

	include ssl.conf;

	server_name <%= d %>;

	location / {
		return 301 https://www.<%= d %>$request_uri;
	}
}
<% end %>
<% mappings.each do |m| %>
server {
	listen 443;

	include ssl.conf;

	server_name <%= m.subdomain %>.<%= domain %>;

	location / {
		if ($http_x_forwarded_proto = "http") {
			return 301 https://$host:<%= Proxy.https_port %>$request_uri;
		}

		proxy_pass <%= m.url %>;
	}
}
<% end %>

server {
	listen 443 default_server;

	include ssl.conf;

	location = /healthcheck {
		return 200 "I am in good health!\n";
	}

	location / {
		if ($http_x_forwarded_proto = "http") {
			return 301 https://$host:<%= Proxy.https_port %>$request_uri;
		}

		return 444;
	}
}
<% apex_domains.each do |d| %>
server {
	listen 443;

	include ssl.conf;

	server_name <%= d %>;

	location / {
		return 301 https://www.<%= d %>$request_uri;
	}
}
<% end %>
<% mappings.each do |m| %>
server {
	listen 443;

	include ssl.conf;

	server_name <%= m.subdomain %>.<%= domain %>;

	location / {
		if ($http_x_forwarded_proto = "http") {
			return 301 https://$host:<%= Proxy.https_port %>$request_uri;
		}

		include /etc/nginx/proxy_params;

		proxy_pass <%= m.url %>;
	}
}
<% end %>

Include proxy params to set our own X-Forwarded-For headers
Include proxy params to set our own X-Forwarded-For headers
