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

	return 301 https://cc.vvvvvvaria.org$request_uri;
}
server {
	listen 443 ssl;
	server_name cc.vvvvvvaria.org;

	root /var/www/html;
	index index.html index.php index.htm index.nginx-debian.html;

	location / {
		try_files $uri $uri/ =404;
		autoindex on;
	}

	ssl_certificate      /etc/letsencrypt/live/cc.vvvvvvaria.org/fullchain.pem;
	ssl_certificate_key  /etc/letsencrypt/live/cc.vvvvvvaria.org/privkey.pem;

	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_buffers 16 16k;
		fastcgi_buffer_size 32k;
		fastcgi_pass unix:/run/php/php7.4-fpm.sock;
		# tip from Michael
		include fastcgi_params;
	}

	# ---------------------------------------------------
	# WIKI 

	# Images
	location /wiki/images {
		# Separate location for images/ so .php execution won't apply
	}
	location /wiki/images/deleted {
		# Deny access to deleted images folder
		deny all;
	}
	# MediaWiki assets (usually images)
	location ~ ^/wiki/resources/(assets|lib|src) {
		try_files $uri 404;
		add_header Cache-Control "public";
		expires 7d;
	}
	# Assets, scripts and styles from skins and extensions
	location ~ ^/wiki/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|wasm)$ {
		try_files $uri 404;
		add_header Cache-Control "public";
		expires 7d;
	}
	# License and credits files
	location ~ ^/wiki/(COPYING|CREDITS)$ {
		default_type text/plain;
	}
	# Handling for Mediawiki REST API, see [[mw:API:REST_API]]
	location /wiki/rest.php/ {
		try_files $uri $uri/ /wiki/rest.php?$query_string;
	}       
	# Handling for the article path (pretty URLs)
	location /wiki/ {
		rewrite ^/wiki/(?<pagename>.*)$ /wiki/index.php;
	}

	# ----------------------------------------------------
	# wiki-to-print

	location /wiki-to-print/ {
		proxy_pass http://localhost:5522;
	}
}