141 lines
3.4 KiB
Plaintext
141 lines
3.4 KiB
Plaintext
server {
|
|
server_name _;
|
|
root /var/www/html;
|
|
|
|
gzip on;
|
|
gzip_types
|
|
application/atom+xml
|
|
application/geo+json
|
|
application/javascript
|
|
application/x-javascript
|
|
application/json
|
|
application/ld+json
|
|
application/manifest+json
|
|
application/rdf+xml
|
|
application/rss+xml
|
|
application/xhtml+xml
|
|
application/xml
|
|
font/eot
|
|
font/otf
|
|
font/ttf
|
|
image/svg+xml
|
|
text/css
|
|
text/javascript
|
|
text/plain
|
|
text/xml;
|
|
gzip_proxied any;
|
|
gzip_min_length 1256;
|
|
|
|
client_max_body_size 5m;
|
|
client_body_timeout 60;
|
|
|
|
|
|
location /sitemap {
|
|
autoindex on;
|
|
}
|
|
|
|
location ~ ^/sitemap/(.*)\.gz$ {
|
|
gzip off;
|
|
default_type text/xml;
|
|
add_header content-encoding gzip;
|
|
}
|
|
|
|
|
|
# Location for wiki's entry points
|
|
location ~ ^/w/(index|load|api|thumb|opensearch_desc|rest|img_auth)\.php$ {
|
|
rewrite ^/w/(.*) /$1 break;
|
|
include fastcgi_params;
|
|
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
|
proxy_set_header X-Forwarded-For "$http_x_forwarded_for, $realip_remote_addr";
|
|
fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on
|
|
}
|
|
|
|
location ~ \.php$ {
|
|
include fastcgi_params;
|
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
|
proxy_set_header X-Forwarded-For "$http_x_forwarded_for, $realip_remote_addr";
|
|
fastcgi_pass 127.0.0.1:9000;
|
|
}
|
|
|
|
location ^~ /maintenance/ {
|
|
return 403;
|
|
}
|
|
|
|
# Images
|
|
location /w/images {
|
|
# Separate location for images/ so .php execution won't apply
|
|
rewrite ^/w/(.*) /$1 break;
|
|
}
|
|
|
|
location /w/images/deleted {
|
|
deny all;
|
|
}
|
|
|
|
# MediaWiki assets (usually images)
|
|
location ~ ^/w/resources/(assets|lib|src) {
|
|
rewrite ^/w/(.*) /$1 break;
|
|
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|wasm)$ {
|
|
rewrite ^/w/(.*) /$1 break;
|
|
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;
|
|
}
|
|
|
|
# License and credits files
|
|
location ~ ^/w/(COPYING|CREDITS)$ {
|
|
rewrite ^/w/(.*) /$1 break;
|
|
default_type text/plain;
|
|
}
|
|
|
|
|
|
# Handling for Mediawiki REST API, see [[mw:API:REST_API]]
|
|
location /w/rest.php/ {
|
|
#rewrite ^/w/(.*) /$1 break;
|
|
try_files $uri $uri/ /rest.php?$query_string;
|
|
}
|
|
|
|
# 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 {
|
|
}
|
|
|
|
location ^~ /cache/ {
|
|
deny all;
|
|
}
|
|
|
|
location /dumps/ {
|
|
root /var/www/html/local;
|
|
autoindex on;
|
|
}
|
|
|
|
# Explicit access to the root website, redirect to main page (adapt as needed)
|
|
location = / {
|
|
return 301 https://$host/wiki/Main_Page;
|
|
}
|
|
|
|
# Every other entry point will be disallowed.
|
|
# Add specific rules for other entry points/images as needed above this
|
|
location / {
|
|
return 301 https://$host/wiki$request_uri;
|
|
#return 404;
|
|
}
|
|
}
|