## WP NintendojoFR
server {
	listen *:443 ssl http2;
	listen [::]:443 ssl http2;
	server_name nintendojo.fr www.nintendojo.fr;
	access_log /var/log/nginx/nintendojo.fr.access.log combined;
	access_log syslog:server=unix:/dev/log combined;
	error_log /var/log/nginx/nintendojo.fr.error.log;
	error_log syslog:server=unix:/dev/log;
	ssl_certificate /etc/x509/www.nintendojo.fr/fullchain.cer;
	ssl_certificate_key /etc/x509/www.nintendojo.fr/www.nintendojo.fr.key;

	root /srv/http/www.nintendojo.fr/;
	index index.html index.htm index.php;

	client_max_body_size 2G;

	# couper les fichiers cachés
	location ~* /(?:uploads|files)/.*\.php$ {
		deny all;
	}

	# couper les fichiers textes du captcha
	location ~* /wp-content/uploads/wpcf7_captcha/.*\.txt$ {
		deny all;
	}

	# Images de la v6
	location ~ ^/images/(.*)$ {
		expires 2w;
		alias /srv/http/archives.nintendojo.fr/v6/images/$1;
	}

	# Images de la v6.7
	location ~ ^/public/(.*)$ {
		expires 2w;
		alias /srv/http/archives.nintendojo.fr/$1;
	}

	# Zolie wallpapers
	location /wallpapers {
		rewrite ^/wallpapers$ /index.php/wallpapers last;
		rewrite ^/wallpapers/([0-9]+) /index.php/wallpapers/?id=$1 last;
		location ~ ^/wallpapers/files(.*)(/.*\.jpg)$ {
			expires 1w;
			alias /srv/http/www.nintendojo.fr/wp-content/plugins/dojomurpapier/files$2;
		}
	}

	# Optimisation des images
	location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
		expires 1w;
		log_not_found off;
	}

	# Interprétation PHP
	location ~ ^/(index).php(/.*)+ {
		fastcgi_split_path_info ^(.+\.php)(/.*)$;
		try_files $fastcgi_script_name =404;
		fastcgi_cache wpdojo;
		fastcgi_cache_key $request_method$host$request_uri;
		fastcgi_cache_valid any 15m;
		fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
		fastcgi_pass unix:/var/run/php/php{{ php_version }}-fpm.sock;
		fastcgi_read_timeout 60;
		include fastcgi_params;
	}

	location ~ \.php$ {
		try_files $uri $uri/ =404;
		fastcgi_pass unix:/var/run/php/php{{ php_version }}-fpm.sock;
		fastcgi_read_timeout 60;
		include fastcgi_params;
	}

	location / {
		try_files $uri $uri/ /index.php$uri?$args;
	}
}
