map $http_upgrade $connection_upgrade {
	default upgrade;
	''      close;
}

server {
{% include './templates/header.conf.j2' %}
	keepalive_timeout    70;
	sendfile             on;
	client_max_body_size 0;
	large_client_header_buffers 4 32k;

	# Referrer-Policy, même si Chrome ne comprendra pas
	add_header Referrer-Policy "same-origin";

	location / {
		try_files $uri @proxy;
	}

	location @proxy {
		proxy_pass http://localhost:3000;
		
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto https;
		
		proxy_set_header Proxy "";
		proxy_pass_header Server;
		
		proxy_buffering off;
		proxy_redirect off;
		
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
		
		tcp_nodelay on;
	}

	location /api/v1/streaming {
		proxy_pass http://localhost:4000;
		
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto https;
		
		proxy_set_header Proxy "";
		
		proxy_buffering off;
		proxy_redirect off;
		
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
		
		tcp_nodelay on;
	}
}

