Closed slrgt closed 11 months ago
For help debugging shorturl setup you'll have more help on one of the relevant MediaWiki talkpage. https://www.mediawiki.org/wiki/Manual:Short_URL
I can't really help especially since I don't even know what kind of web server you're using.
I’ve tried that and i never get a reply. Im using nginx. Can you atleast explain what im supposed to do with the second part of your website?
On Tue, Sep 5, 2023 at 7:41 PM, Daniel Friesen @.***(mailto:On Tue, Sep 5, 2023 at 7:41 PM, Daniel Friesen < wrote:
For help debugging shorturl setup you'll have more help on one of the relevant MediaWiki talkpage. https://www.mediawiki.org/wiki/Manual:Short_URL
I can't really help especially since I don't even know what kind of web server you're using.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
You mean the part where it explains what nginx configuration you need to add to your site's current nginx configuration?
Yes, I don't understand where i need to copy paste the information to. As in, im not sure if I should replace everything in the /etc/nginx/nginx.conf file with that information or place it in a specific section
Find where your MediaWiki installation is configured and update that. This could be in that file or in another sites-??? folder. It'll probably already have a fastcgi_pass somewhere in it. Try to merge things into the current config where they look similar.
The service can't read your Nginx config and there are many different ways it can be configured. So the service can't give you the exact Nginx config to use.
Sorry I don't mean to be a bother. I used nginx -t
to find that the nginx.conf being used is located in /etc/nginx/nginx.conf
but it doesn't include anything similar to the information listed on the redwerks service which is why I'm so confused. This is what my nginx.conf has inside:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 2000;
}
http {
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/sites-enabled/*.conf;
}
See this line include /etc/nginx/sites-enabled/*.conf;
. That means that there are also config files in the /etc/nginx/sites-enabled
folder and it's very likely that one of those has the block of configuration that actually defines your MediaWiki site's hosting.
Ah, thanks! In /etc/nginx/sites-enabled
I have cockpit.conf
mediawiki_http.conf
and mediawikihttps.conf` I assume I have to do add the information it in both the http and https conf files? Can you let me know where in the conf files I should copy paste the infromation to? Here is the http.conf:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
#server_name mediawiki.example.com;
return 301 https://$host$request_uri;
root /var/www/html/;
index index.php;
# set max upload size
client_max_body_size 2G;
fastcgi_buffers 64 4K;
server_tokens off;
include /etc/nginx/site-extras/*.conf;
access_log /var/log/nginx/mediawiki_http_access.log combined;
error_log /var/log/nginx/mediawiki_http_error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ^~ /mw-config/ {
auth_basic "Restricted"; #SAFE TO REMOVE
auth_basic_user_file /etc/nginx/htpasswd/mwadmin; #SAFE TO REMOVE
location ~* \.(htaccess|htpasswd) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
}
location ~* \.(htaccess|htpasswd) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
# set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
access_log off;
}
}
/mw-config is where your MediaWiki installation is? If that's the case:
location ~* \.(htaccess|htpasswd)
block can be dropped as the location ~ /.ht { deny all; }
line does the sameI think my mediawiki is installed in /var/www/html/ since that's where LocalSettings and /images/ and everything is
Oh sorry, mw-config
could be a new thing.
In that case keep the mw-config block. And replace the location /
block with everything in between the # [...]
parts of the example.
Edit: Also presumably remove the location ~ \.php(?:$|/)
block
Thanks! Sorry for all the questions. Just to make sure I'm doing it correctly, I have to replace everything in the red of this screenshot right?
No, delete these blocks:
location / {
location ~* \.(htaccess|htpasswd) {
location ~ \.php(?:$|/) {
Keep the rest. The favicon, robots.txt, mw-config, and static assets rules each to something else you still want.
Ok I erased
and now my mediawiki_http.conf is this:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
#server_name mediawiki.example.com;
return 301 https://$host$request_uri;
root /var/www/html/;
index index.php;
# set max upload size
client_max_body_size 2G;
fastcgi_buffers 64 4K;
server_tokens off;
include /etc/nginx/site-extras/*.conf;
access_log /var/log/nginx/mediawiki_http_access.log combined;
error_log /var/log/nginx/mediawiki_http_error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# [...]
# Location for the wiki's root
location / {
# Do this inside of a location so it can be negated
location ~ \.php$ {
try_files $uri $uri/ =404; # Don't let php execute non-existent php files
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
location /images {
# Separate location for images/ so .php execution won't apply
location ~ ^/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ {
# Thumbnail handler for MediaWiki
# This location only matches on a thumbnail's url
# If the file does not exist we use @thumb to run the thumb.php script
try_files $uri $uri/ @thumb;
}
}
location /images/deleted {
# Deny access to deleted images folder
deny all;
}
# Deny access to folders MediaWiki has a .htaccess deny in
location /cache { deny all; }
location /languages { deny all; }
location /maintenance { deny all; }
location /serialized { deny all; }
# Just in case, hide .svn and .git too
location ~ /.(svn|git)(/|$) { deny all; }
# Hide any .htaccess files
location ~ /.ht { deny all; }
# Uncomment the following code if you wish to hide the installer/updater
## Deny access to the installer
#location /mw-config { deny all; }
# Handling for the article path
location /c {
include /etc/nginx/fastcgi_params;
# article path should always be passed to index.php
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass 127.0.0.1:9000;
}
# Thumbnail 404 handler, only called by try_files when a thumbnail does not exist
location @thumb {
# Do a rewrite here so that thumb.php gets the correct arguments
rewrite ^/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2;
rewrite ^/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2&archived=1;
# Run the thumb.php script
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/thumb.php;
fastcgi_pass 127.0.0.1:9000;
}
# [...]
}
location ^~ /mw-config/ {
auth_basic "Restricted"; #SAFE TO REMOVE
auth_basic_user_file /etc/nginx/htpasswd/mwadmin; #SAFE TO REMOVE
location ~* \.(htaccess|htpasswd) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
}
# set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
access_log off;
}
}
Does that look correct?
Yup pretty much.
You'll want to erase this bit. That extra }
is going to make a syntax error.
# [...]
}
You can also delete the other # [...]
comment.
After updating it (and erasing the # [...] } ) I get File Not Found
when I go to my wiki now
This is my mediawiki_http.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
#server_name mediawiki.example.com;
return 301 https://$host$request_uri;
root /var/www/html/;
index index.php;
# set max upload size
client_max_body_size 2G;
fastcgi_buffers 64 4K;
server_tokens off;
include /etc/nginx/site-extras/*.conf;
access_log /var/log/nginx/mediawiki_http_access.log combined;
error_log /var/log/nginx/mediawiki_http_error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Location for the wiki's root
location / {
# Do this inside of a location so it can be negated
location ~ \.php$ {
try_files $uri $uri/ =404; # Don't let php execute non-existent php files
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
location /images {
# Separate location for images/ so .php execution won't apply
location ~ ^/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ {
# Thumbnail handler for MediaWiki
# This location only matches on a thumbnail's url
# If the file does not exist we use @thumb to run the thumb.php script
try_files $uri $uri/ @thumb;
}
}
location /images/deleted {
# Deny access to deleted images folder
deny all;
}
# Deny access to folders MediaWiki has a .htaccess deny in
location /cache { deny all; }
location /languages { deny all; }
location /maintenance { deny all; }
location /serialized { deny all; }
# Just in case, hide .svn and .git too
location ~ /.(svn|git)(/|$) { deny all; }
# Hide any .htaccess files
location ~ /.ht { deny all; }
# Uncomment the following code if you wish to hide the installer/updater
## Deny access to the installer
#location /mw-config { deny all; }
# Handling for the article path
location /c {
include /etc/nginx/fastcgi_params;
# article path should always be passed to index.php
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass 127.0.0.1:9000;
}
# Thumbnail 404 handler, only called by try_files when a thumbnail does not exist
location @thumb {
# Do a rewrite here so that thumb.php gets the correct arguments
rewrite ^/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2;
rewrite ^/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2&archived=1;
# Run the thumb.php script
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/thumb.php;
fastcgi_pass 127.0.0.1:9000;
}
location ^~ /mw-config/ {
auth_basic "Restricted"; #SAFE TO REMOVE
auth_basic_user_file /etc/nginx/htpasswd/mwadmin; #SAFE TO REMOVE
location ~* \.(htaccess|htpasswd) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
}
# set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
access_log off;
}
}
and this is my mediawiki_https.conf:
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name _;
#server_name mediawiki.example.com;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
root /var/www/html/;
index index.php;
# set max upload size
client_max_body_size 2G;
fastcgi_buffers 64 4K;
server_tokens off;
include /etc/nginx/site-extras/*.conf;
access_log /var/log/nginx/mediawiki_https_access.log combined;
error_log /var/log/nginx/mediawiki_https_error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ^~ /mw-config/ {
auth_basic "Restricted"; #SAFE TO REMOVE
auth_basic_user_file /etc/nginx/htpasswd/mwadmin; #SAFE TO REMOVE
location ~* \.(htaccess|htpasswd) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
}
location ~* \.(htaccess|htpasswd) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
# set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
access_log off;
}
}
server {
listen 443 ssl ;
listen [::]:443 ssl ;
server_name covidwiki.org www.covidwiki.org; # managed by Certbot
#server_name mediawiki.example.com;
ssl_certificate /etc/letsencrypt/live/www.covidwiki.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.covidwiki.org/privkey.pem; # managed by Certbot
root /var/www/html/;
index index.php;
# set max upload size
client_max_body_size 2G;
fastcgi_buffers 64 4K;
server_tokens off;
include /etc/nginx/site-extras/*.conf;
access_log /var/log/nginx/mediawiki_https_access.log combined;
error_log /var/log/nginx/mediawiki_https_error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Location for the wiki's root
location / {
# Do this inside of a location so it can be negated
location ~ \.php$ {
try_files $uri $uri/ =404; # Don't let php execute non-existent php files
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
location /images {
# Separate location for images/ so .php execution won't apply
location ~ ^/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ {
# Thumbnail handler for MediaWiki
# This location only matches on a thumbnail's url
# If the file does not exist we use @thumb to run the thumb.php script
try_files $uri $uri/ @thumb;
}
}
location /images/deleted {
# Deny access to deleted images folder
deny all;
}
# Deny access to folders MediaWiki has a .htaccess deny in
location /cache { deny all; }
location /languages { deny all; }
location /maintenance { deny all; }
location /serialized { deny all; }
# Just in case, hide .svn and .git too
location ~ /.(svn|git)(/|$) { deny all; }
# Hide any .htaccess files
location ~ /.ht { deny all; }
# Uncomment the following code if you wish to hide the installer/updater
## Deny access to the installer
#location /mw-config { deny all; }
# Handling for the article path
location /c {
include /etc/nginx/fastcgi_params;
# article path should always be passed to index.php
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass 127.0.0.1:9000;
}
# Thumbnail 404 handler, only called by try_files when a thumbnail does not exist
location @thumb {
# Do a rewrite here so that thumb.php gets the correct arguments
rewrite ^/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2;
rewrite ^/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2&archived=1;
# Run the thumb.php script
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/thumb.php;
fastcgi_pass 127.0.0.1:9000;
}
location ^~ /mw-config/ {
auth_basic "Restricted"; #SAFE TO REMOVE
auth_basic_user_file /etc/nginx/htpasswd/mwadmin; #SAFE TO REMOVE
location ~* \.(htaccess|htpasswd) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
}
# set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
access_log off;
}
}
I'll need more information about what url you used and you'll need to try a couple urls to figure out what kind of error is happening.
On Fri, Sept 8, 2023, 4:51 p.m. slrgt @.***> wrote:
After updating it (and erasing the # [...] } ) I get File Not Found when I go to my wiki now
— Reply to this email directly, view it on GitHub https://github.com/redwerks/mediawiki-shorturl-builder/issues/14#issuecomment-1712343774, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAANBF77TMLMRSAFV5IF7LTXZOVPRANCNFSM6AAAAAA4MLJQSI . You are receiving this because you modified the open/close state.Message ID: @.***>
Ok, the error happened when i went to the main website url covidwiki.org the shorturl im trying to use is c
If you got at 500 error it would be an error in the configuration which we could look at logs for. Since it's a 404 error (page not found) you need to try other urls to see what are working and what are broken to isolate what part of the config is missing.
Besides the homepage also try /index.php?title=Page&action=edit
and /c/Page
and see what you get there.
If i go to https://covidwiki.org/index.php?title=Page&action=edit it just says File not found
Same for https://covidwiki.org/c/Covid-19/index.php?title=Page&action=edit
Or any iteration
is the https.conf file correct? I notice there is two server {
sections. do both need to have the updated section from the redwerks conf?
I also noticed this section in it include /etc/nginx/site-extras/*.conf;
could that be causing the error? the conf file in there is phpmyadmin.conf which has this
location ^~ /mysqladmin {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd/phpmyadmin;
access_log /var/log/nginx/phpmyadmin_access.log combined;
error_log /var/log/nginx/phpmyadmin_error.log;
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PHP_FLAG "session.auto_start=off \n mbstring.encoding_translation=off";
fastcgi_param PHP_VALUE "assert.active=0";
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 60s;
}
}
is the https.conf file correct? I notice there is two
server {
sections. do both need to have the updated section from the redwerks conf?
The second block contains server_name covidwiki.org www.covidwiki.org;
so that is what will be used for that domain. The other will be used as a fallback for other domains.
I also noticed this section in it
include /etc/nginx/site-extras/*.conf;
could that be causing the error? the conf file in there is phpmyadmin.conf which has this
That just defines something for a /mysqladmin
path.
Maybe try updating the wiki root block to look more like the original version in your config file.
# Location for the wiki's root
location / {
# Do this inside of a location so it can be negated
location ~ \.php$ {
try_files $uri $uri/ =404; # Don't let php execute non-existent php files
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass 127.0.0.1:9000;
}
}
I updated it to that but now the website is completely unreachable :\
Isn't there a way to debug why everything works perfectly except for files not using the short url when I have it how I had it before?
I restored the changes back so the site is working again and heres an example. I uploaded a file and when i go to list of uploaded files the thumbnail displays. If you click file
you can go to the image https://covidwiki.org/images/a/a2/Pulse-browser_iJIPUXuGhh.png
but if i click on the filename it goes to this 404 page https://covidwiki.org/c/File:Pulse-browser_iJIPUXuGhh.png notice the url has /c/ like if its an article. Replacing the /c/ with the index.php format goes to the file https://covidwiki.org/index.php?title=File:Pulse-browser_iJIPUXuGhh.png
It seems like for some reason shortUrls is working on everything except for files and that is causing the error
When I try going to a file i get 404 Not Found but if I add index.php?title= before the File:
fileName
I can visit the file. This is breaking image uploads and file uploads for me and I can't seem to find a fix.my LocalSettings are $wgScriptPath = ""; $wgArticlePath = "/$1"; $wgUsePathInfo = true; $wgScriptExtension = ".php";
Also, I dont understand the nginx.conf section. Am I supposed to copy paste the information to the bottom of /etc/nginx/nginx.conf? Or erase everything in the /etc/nginx/nginx.conf file and replace it with the information at the bottom of shorturls.redwerks.org?