user __NGINX_USER__;
pid /var/run/nginx.pid;

worker_processes auto;
worker_rlimit_nofile 100000;

events {
	worker_connections 9000;
	multi_accept on;
}

http {
	# DNS servers for on-demand resolution, change if desired
	resolver 8.8.8.8;

	# include default mime types
	include __NGINX_ETC_FOLDER__/mime.types;
	default_type application/octet-stream;

	# HTTP basic configuration
	include mempool/production/nginx/http-basic.conf;
	include mempool/production/nginx/http-acl.conf;
	include mempool/production/nginx/http-proxy-cache.conf;
	include mempool/production/nginx/http-language.conf;

	# match preview/unfurl bot user-agents
	map $http_user_agent $unfurlprefix {
		default "";
	}

	# mempool configuration
	include mempool/production/nginx/upstream-mempool.conf;

	# esplora configuration
	include mempool/production/nginx/upstream-esplora.conf;
	include mempool/production/nginx/server-esplora.conf;

	# MEMPOOL.NINJA
	server {
		# clearnet v4/v6
		#listen 443 ssl http2;
		#listen [::]:443 ssl http2;
		server_name _;

		# set cors headers if necessary
		set $cors_approved_origin '';

		# tor v3
		listen 127.0.0.1:81;
		set $onion "__NGINX_MEMPOOL_ONION__";

		# for services from mempool.space like contributors on about page
		set $mempoolSpaceServices "https://mempool.space";
		set $mempoolSpaceUnfurler "http://127.0.0.1:8001";

		# for mempool daemons, see upstream-mempool.conf
		set $mempoolMainnet "http://mempool-bitcoin-mainnet";
		set $mempoolMainnetLightning "http://mempool-bitcoin-mainnet-lightning";
		set $mempoolTestnet "http://mempool-bitcoin-testnet";
		set $mempoolTestnetLightning "http://mempool-bitcoin-testnet-lightning";
		set $mempoolTestnet4 "http://mempool-bitcoin-testnet4";
		set $mempoolSignet "http://mempool-bitcoin-signet";
		set $mempoolSignetLightning "http://mempool-bitcoin-signet-lightning";

		# for blockstream/esplora daemons, see upstream-esplora.conf
		set $esploraMainnet "http://esplora-bitcoin-mainnet";
		set $esploraTestnet "http://esplora-bitcoin-testnet";
		set $esploraTestnet4 "http://esplora-bitcoin-testnet4";
		set $esploraSignet "http://esplora-bitcoin-signet";

		# filesystem paths
		root /mempool/public_html/mainnet/;
		access_log /var/log/nginx/mempool-access.log;
		error_log /var/log/nginx/mempool-error.log;

		# site configuration
		include mempool/production/nginx/server-mempool.conf;
	}
	# LIQUID.PLACE
	server {
		# clearnet v4/v6
		#listen 443 ssl http2;
		#listen [::]:443 ssl http2;
		server_name _;

		# set cors headers if necessary
		set $cors_approved_origin '';

		# tor v3
		listen 127.0.0.1:83;
		set $onion "__NGINX_LIQUID_ONION__";

		# for services from mempool.space like contributors on about page
		set $mempoolSpaceServices "https://mempool.space";
		set $mempoolSpaceUnfurler "http://127.0.0.1:8001";

		# for mempool daemons, see upstream-mempool.conf
		set $mempoolMainnet "http://mempool-liquid-mainnet";
		set $mempoolTestnet "http://mempool-liquid-testnet";

		# for blockstream/esplora daemon, see upstream-esplora.conf
		set $esploraMainnet "http://esplora-liquid-mainnet";
		set $esploraTestnet "http://esplora-liquid-testnet";

		# filesystem paths
		root /mempool/public_html/liquid/;
		access_log /var/log/nginx/liquid-access.log;
		error_log /var/log/nginx/liquid-error.log;

		# site configuration
		include mempool/production/nginx/server-liquid.conf;
	}
}
