server {
	listen 81 default;
	server_name nginxproxymanager-dev;

	location /api {
		return 302 /api/;
	}

	root /app/backend;
	location /api/coverage {
		try_files /index.html /coverage.html;
	}

	# go server
	location /api/ {
		add_header                X-Served-By $host;
		chunked_transfer_encoding off;
		proxy_buffering           off;
		proxy_cache               off;
		proxy_http_version        1.1;
		proxy_set_header          Host $host;
		proxy_set_header          Connection '';
		proxy_set_header          X-Forwarded-Scheme $scheme;
		proxy_set_header          X-Forwarded-Proto  $scheme;
		proxy_set_header          X-Forwarded-For    $remote_addr;
		proxy_set_header          X-Accel-Buffering  no;
		proxy_pass                http://127.0.0.1:3000/api/;
	}

	# go server
	location /oauth/ {
		add_header                X-Served-By $host;
		chunked_transfer_encoding off;
		proxy_buffering           off;
		proxy_cache               off;
		proxy_http_version        1.1;
		proxy_set_header          Host $host;
		proxy_set_header          Connection '';
		proxy_set_header          X-Forwarded-Scheme $scheme;
		proxy_set_header          X-Forwarded-Proto  $scheme;
		proxy_set_header          X-Forwarded-For    $remote_addr;
		proxy_set_header          X-Accel-Buffering  no;
		proxy_pass                http://127.0.0.1:3000/oauth/;
	}

	location ~ .html {
		try_files $uri =404;
	}

	# vite dev server
	location / {
		add_header            X-Served-By $host;
		proxy_http_version    1.1;
		proxy_set_header Host $host;
		proxy_set_header      Upgrade $http_upgrade;
		proxy_set_header      Connection "Upgrade";
		proxy_set_header      X-Forwarded-Scheme $scheme;
		proxy_set_header      X-Forwarded-Proto  $scheme;
		proxy_set_header      X-Forwarded-For    $remote_addr;
		proxy_pass            http://127.0.0.1:5173;
	}
}
