server {
	listen 81;
	listen [::]:81;

	root /usr/share/radangel/html;

	index index.html index.htm;

	server_name _;

	location / {
		try_files $uri $uri/ =404;
	}

	location /data/hist.tsv {
		alias /tmp/stats.tsv;
	}

	location /data/stream.tsv { 
		alias /tmp/event.tsv;
	}

	location /data/stream.ws {
		proxy_http_version 1.1;
		proxy_set_header Upgrade         $http_upgrade;
		proxy_set_header Connection      "upgrade";

		proxy_set_header Host            $host; # $http_host;
		proxy_set_header X-Real-IP       $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-NginX-Proxy   true;

		proxy_read_timeout 3600;
		proxy_buffering off;
		tcp_nodelay on;

		error_page 502 = /data/stream.tsv; # serve http for non-ws clients

		proxy_pass http://127.0.0.1:5800/websockify;
	}

}
