server {
	listen 80;
	server_name {{ server_name }};

	location /.well-known/acme-challenge {
		default_type "text/plain";
		root /tmp/letsencrypt;
	}
	location / {
		rewrite ^ https://$host$request_uri? permanent;
	}
}

server {
	listen 443 ssl;
	server_name {{ server_name }};
	root /home/skyreach/htdocs/skyreach_site/static;

	access_log /var/log/nginx/access_skyreach.log;
	error_log /var/log/nginx/error_skyreach.log;

	location /media {
		alias /home/skyreach/htdocs/skyreach_site/media;
		expires 30d;
		add_header Pragma public;
		add_header Cache-Control "public";
	}
	location /static {
		alias /home/skyreach/htdocs/skyreach_site/static;
		expires 30d;
		add_header Pragma public;
		add_header Cache-Control "public";
	}
	location /robots.txt {
		alias /home/skyreach/htdocs/skyreach_site/static/robots.txt;
		expires 30d;
		add_header Pragma public;
		add_header Cache-Control "public";
	}

	location /remote-event/ {
		proxy_pass http://127.0.0.1:6586/;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_read_timeout 12h;
	}

	location / {
		uwsgi_pass unix:///home/skyreach/.skyreach/uwsgi.sock;
		include /etc/nginx/uwsgi_params;
	}

	# APT proxy urls
	location /fr.archive.ubuntu.com/ubuntu {
		proxy_pass http://127.0.0.1:3142;
	}
	location /security.ubuntu.com/ubuntu {
		proxy_pass http://127.0.0.1:3142;
	}
	location /old-releases.ubuntu.com/ubuntu {
		proxy_pass http://127.0.0.1:3142;
	}
}
