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

	root /var/www/html;

	index index.html index.htm index.nginx-debian.html;

	server_name _;

    error_page 502 /502.html;

    location /502.html {
    }

	location / {
		try_files $uri $uri/ =404;
		#return 302 http://$host/iris;
	}

	location /iris {
		proxy_pass http://127.0.0.1:6680/iris;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";

          # VNC connection timeout
          proxy_read_timeout 61s;

          # Disable cache
          proxy_buffering off;

	}
	location /mopidy {
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $host;
		proxy_pass http://127.0.0.1:6680/mopidy;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";

          # VNC connection timeout
          proxy_read_timeout 61s;

          # Disable cache
          proxy_buffering off;

	}

    location /image {
            proxy_pass          http://127.0.0.1:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    }

    location /jsonrpc {
          proxy_http_version 1.1;
          proxy_pass http://127.0.0.1:8080;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";

          # VNC connection timeout
          proxy_read_timeout 61s;

          # Disable cache
          proxy_buffering off;

    }

    location /websockify {
          proxy_pass http://127.0.0.1:6080/;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";

          # VNC connection timeout
          proxy_read_timeout 61s;

          # Disable cache
          proxy_buffering off;
    }

    location /vnc {
        alias /var/www/noVNC;
        autoindex on;
        index vnc.html;
        try_files $uri $uri/ vnc.html;
    }

    location /projektor/ {
        proxy_pass http://127.0.0.1:6999/;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location /projector/ {
        proxy_pass http://projektor.kontor.lapikud.ee/cgi-bin/;
    }
}

