I have NGINX setup to serve content over localhost with HTTPS. Using the following location block, I can serve mediawiki just fine (it is in the /w
folder)
location ~ /w/(.*)(\.php)?$ {
index index.php index.html;
try_files $uri $uri.php /w/index.php =404;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
However, when I try to setup short urls (https://localhost/wiki/Some_Page for example) using this guide, I always get 404 file not found. I'm using PHP-FPM as the upstream, for reference. Here is the full configuration I'm using with NGINX to achieve short URLs
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
log_format compression '$time_local - "$uri" $status "$http_referer" $request_filename';
access_log /Users/nicholas.chambers/log/nginx/access.log compression;
error_log /Users/nicholas.chambers/log/nginx/error.log;
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name localhost;
ssl_certificate /Users/nicholas.chambers/nginx/ssl/cert.pem;
ssl_certificate_key /Users/nicholas.chambers/nginx/ssl/private.key;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
ssl_prefer_server_ciphers on;
ssl_trusted_certificate /Users/nicholas.chambers/ca/intermediate/certs/chain.pem;
root /Users/nicholas.chambers;
allow 127.0.0.0/8;
deny all;
location ~ /wordpress/(.*)(\.php)?$ {
index index.php index.html;
try_files $uri $uri.php /wordpress/$1/index.php /wordpress/index.php =404;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
location ~ ^/w/(index|load|api|thumb|opensearch_desc)\.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/w/$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on
}
location /w/images {
}
location /w/images/deleted {
deny all;
}
location ~ ^/w/resources/(assets|lib|src) {
try_files $uri 404;
add_header Cache-Control "public";
expires 7d;
}
location ~ ^/w/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg)$ {
try_files $uri 404;
add_header Cache-Control "public";
expires 7d;
}
location = /favicon.ico {
alias /w/images/6/64/Favicon.ico;
add_header Cache-Control "public";
expires 7d;
}
location /wiki/ {
rewrite ^/wiki/(?<pagename>.*)$ /w/index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/w/index.php;
fastcgi_param PATH_INFO $pagename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_pass 127.0.0.1:9000;
}
location = /robots.txt {
}
}
}
I haven't made any changes to my LocalSettings.php, except for adding the following data
$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
Thanks in advance!