Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mediawiki profile needs tuning #5

Open
dale-c-anderson opened this issue Apr 8, 2020 · 1 comment
Open

mediawiki profile needs tuning #5

dale-c-anderson opened this issue Apr 8, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@dale-c-anderson
Copy link
Member

If someone creates a page with ".php" at the end of the title, the nginx config thinks an actual php page is being requested.

The mediawiki profile needs to explicitly handle mediawiki's php locations, and let everything else be handled by the rewrite.

Refer to https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx for locations.

@dale-c-anderson
Copy link
Member Author

https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx
at the time of this issue,

server {
	# [...]

	# Location for wiki's entry points
	location ~ ^/w/(index|load|api|thumb|opensearch_desc)\.php$ {
		include /etc/nginx/fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on
	}
	
	# Images
	location /w/images {
		# Separate location for images/ so .php execution won't apply
	}
	location /w/images/deleted {
		# Deny access to deleted images folder
		deny all;
	}
	# MediaWiki assets (usually images)
	location ~ ^/w/resources/(assets|lib|src) {
		try_files $uri 404;
		add_header Cache-Control "public";
		expires 7d;
	}
	# Assets, scripts and styles from skins and extensions
	location ~ ^/w/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg)$ {
		try_files $uri 404;
		add_header Cache-Control "public";
		expires 7d;
	}
	# Favicon
	location = /favicon.ico {
		alias /w/images/6/64/Favicon.ico;
		add_header Cache-Control "public";
		expires 7d;
	}
	
	## Uncomment the following code if you wish to use the installer/updater
	## installer/updater
	#location /w/mw-config/ {
	#	# Do this inside of a location so it can be negated
	#	location ~ \.php$ {
	#		include /etc/nginx/fastcgi_params;
	#		fastcgi_param SCRIPT_FILENAME $document_root/w/mw-config/$fastcgi_script_name;
	#		fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on
	#	}
	#}
	
	# Handling for the article path (pretty URLs)
	location /wiki/ {
		rewrite ^/wiki/(?<pagename>.*)$ /w/index.php;
	}

	# Allow robots.txt in case you have one
	location = /robots.txt {
	}
	# Explicit access to the root website, redirect to main page (adapt as needed)
	location = / {
		return 301 /wiki/Main_Page;
	}

	# Every other entry point will be disallowed.
	# Add specific rules for other entry points/images as needed above this
	location / {
		return 404;
	}
}

@dale-c-anderson dale-c-anderson added the bug Something isn't working label Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant