server {
    listen %%interface%%:%%port%% default_server;
    server_name netalertx;
    proxy_buffering off;
    include /etc/nginx/includes/server_params.conf;
    include /etc/nginx/includes/proxy_params.conf;

    location / {
        proxy_pass http://127.0.0.1:20211/;
        rewrite ^%%ingress_entry%%/?(.*)$ /$1 break;
    	sub_filter_once off;
	sub_filter_types *;
	sub_filter 'href="/' 'href="%%ingress_entry%%/';
	sub_filter '(?>$host)/css/' '%%ingress_entry%%/css/';
	sub_filter '(?>$host)/js/'  '%%ingress_entry%%/js/';
	sub_filter '/img/' '%%ingress_entry%%/img/';
	sub_filter '/lib/' '%%ingress_entry%%/lib/';
	sub_filter '/php/' '%%ingress_entry%%/php/';

	# Next three lines allow websockets
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";

        # Allow downloading fragments
        proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;

	# Improve ip handling
	proxy_hide_header X-Powered-By;
	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 $scheme;
	proxy_set_header Accept-Encoding "";
	proxy_connect_timeout 30m;
	proxy_send_timeout 30m;
	proxy_read_timeout 30m;
	add_header X-Frame-Options "SAMEORIGIN";
    }
}
