server {
	listen 80 default_server;
	listen [::]:80 default_server;

	server_name _;

	access_log off;

	location /.well-known {
		root /var/www/html;
	}

	location / {
		return 308 https://$host$request_uri;
	}
}

server {
	listen 443 ssl http2 default_server;
	listen [::]:443 ssl http2 default_server;

	server_name _;

	access_log off;

	ssl_certificate /etc/letsencrypt/live/assets.cepharum.de/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/assets.cepharum.de/privkey.pem;

	location / {
		root /var/www/html;
	}
}

#
# Google Fonts
#
server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;

	server_name google-fonts.cepharum.de;

	ssl_certificate /etc/letsencrypt/live/assets.cepharum.de/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/assets.cepharum.de/privkey.pem;

	access_log off;

	location /s/ {
		proxy_pass https://fonts.gstatic.com;
	}

	location / {
		proxy_pass https://fonts.googleapis.com;
		proxy_set_header Accept-Encoding "";
		sub_filter https://fonts.gstatic.com "https://google-fonts.cepharum.de";
		sub_filter_once off;
		sub_filter_types *;
	}
}

#
# Typekit
#
server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;

	server_name typekit.cepharum.de;

	ssl_certificate /etc/letsencrypt/live/assets.cepharum.de/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/assets.cepharum.de/privkey.pem;

	location /p/ {
		proxy_pass https://p.typekit.net/;
	}

	location /use/ {
		proxy_pass https://use.typekit.net/;
	}

	location / {
		proxy_pass https://use.typekit.net;
		proxy_set_header Accept-Encoding "";
		sub_filter https://p.typekit.net "https://typekit.cepharum.de/p";
		sub_filter https://use.typekit.net "https://typekit.cepharum.de/use";
		sub_filter_once off;
		sub_filter_types *;
	}
}
