server {
	listen 80 default_server;
	listen [::]:80 default_server;
    # server_name _;
	
    include /data/config/nginx.conf;

  # if slow to open site, consider uncomment next two lines
  # ssl_stapling on;
  # ssl_stapling_verify on;

	index index.html index.lua index.php;
	root  /data/umapp/app/html;
	
	access_log /data/log/umapp_access.log;
	error_log /data/log/umapp_error.log;

	# Expire rules for static content
	# location = / {
    #     add_header Cache-Control "no-cache, no-store";
    # }
    # location = /index.html {
    #     add_header Cache-Control "no-cache, no-store";
    # }
    # location = /version.txt {
    #     add_header Cache-Control "no-cache, no-store";
    # }
    # cache.appcache, your document html and data
    #location ~* \.(?:manifest|appcache|html?|xml|json|webmanifest)$ {
    #  expires -1;
    #  # access_log logs/static.log; # I don't usually include a static log
    #}

	location / {
		try_files $uri $uri/ /index.html;
	}

  # deny uploaded php and lua script to run!!
  location ~ ^/(file|upload)/.*\.(php|lua|umd)$ {
          deny all;
          return 404;
  }
	
  location ~ \.lua$|/registerhandler$|/registerpage$ {
		proxy_pass http://localhost:10504;
		proxy_pass_request_headers on;
		proxy_set_header Authorization $http_authorization;
		proxy_pass_header Authorization;
		gzip    off;
		proxy_read_timeout 300;
		proxy_connect_timeout 300;
		proxy_redirect   off;
		client_max_body_size 128m;
		proxy_set_header 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-Forwarded-Proto  $scheme;
		proxy_set_header X-Forwarded-Protocal  $scheme;
		proxy_set_header X-Url-Scheme  $scheme;
	}

	location /websocket {
		proxy_pass http://localhost:10504/websocket;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_read_timeout 3600s;
	}

	location /signal {
		proxy_pass http://localhost:10504/video/signal.lua;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_read_timeout 3600s;
	}

	location /signal.ump {
		proxy_pass http://localhost:10504/video/signal.lua;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_read_timeout 3600s;
	}

	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		index index.php index.html index.htm;
		chunked_transfer_encoding off;
		fastcgi_read_timeout 3600s;
		fastcgi_pass unix:/run/php/php8.2-fpm.sock;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param SCRIPT_NAME $fastcgi_script_name;
		fastcgi_buffer_size 128k;
		fastcgi_buffers 256 16k;
		fastcgi_busy_buffers_size 256k;
		fastcgi_temp_file_write_size 256k;
		client_max_body_size 128m;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
}

