Kleine Pimmel Scripts


server {
	#listen 443 ssl;
	listen 80;
	
	server_name "~^(?<sub>.+)\.domain\.tld$";

	location ^~ /subdir {
		alias /do/not/proxy/subdir;
	}

	if ($sub ~ ^\d+$) {
		set $isnum 1;
		set $passon "https://0.0.0.0:${sub}";
	}

	if ($isnum != 1) {
		return 404;
	}


	location / {
		proxy_pass $passon;
		proxy_buffering off;
		proxy_set_header Range $http_range;
		proxy_set_header If-Range $http_if_range;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header Host $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
	}


}