Topic on Project:Support desk

Mediawiki 1.35.1 and VisualEditor behind a proxy not working

13
Shahim Essaid (talkcontribs)

I'm trying MW 1.35.1 in a docker compose setup. The visual editor is working as expected without any additional configuration when the docker image is port mapped to port 80 on the host as it is also on port 80 in the docker image.


However, if I try to reach the Mediawiki docker container (where MW is running on port 80) through an HAProxy container that forwards port 8080 from the browser to port 80 on the Mediawiki container the visual editor breaks. I think it has something to do with having to configure the URLs for Parsoid, RESTBase, etc. but I'm not sure how to do this. Most of the existing documentation is for previous versions that needed manual installation and configuration of VE and its dependencies.

Any hints for what is needed in LocalSettings.php to deal with the proxying from port 8080 to 80, or any other proxy related configuration on the MW side? Thanks!

Shahim Essaid (talkcontribs)

It appears that simply removing the port from the $wgServer value might have fixed this problem. It was set to the port from the proxy (8080) but MW was running under Apache on port 80. I'd still like to understand how this works for MW 1.35 in terms of adjusting ULRs/Ports for the Parsoid/RESTBase auto configuration that is part of 1.35.

Jeroen De Dauw (talkcontribs)

Similar issue when using the stock MediaWiki 1.35 Docker image and enabling VisualEditor. Would be nice to have some docs on this!

Dragan Espenschied (talkcontribs)

Here is running Mediawiki 1.35.0 via the default Docker container on my local dev laptop, and added VisualEditor. Upon launching, VE complains: Error contacting the Parsoid/RESTBase server: (curl error: 7) Couldn't connect to server -- apparently the auto configutation is getting something wrong.


This is the apache log entry that apparently produces the error:


172.22.0.1 - - [25/Jan/2021:13:54:10 +0000] "GET /w/api.php?action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en&formatversion=2&oldid=144730 HTTP/1.1" 200 858 "http://localhost:8181/w/index.php?title=Main_Page&veaction=edit" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0"


Enabling or disabling short URLs doesn't seem to make a difference.


The documentation is a bit confusing so I am at a loss of how to find the error. There is no entry in the apache log or the browser console that would hint at what URL VE is trying to access.


Any help greatly appreciated!

92.45.61.4 (talkcontribs)

Any progress about this issue? I'm having the same problem using mediawiki docker image (1.35) with visual editor


Kind regards

82.120.36.23 (talkcontribs)

Hello, same probleme here.

Many test with :

"require env visualeditor" or "require local" in apache configuration

or this in LocalSettings.php

$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;

There is no solution for parsoid behind reverse proxy with private wiki, help please :)

DFichtmueller (talkcontribs)

I encountered this issue as well, when trying to run Mediawiki 1.35 on Docker (actually the Wikibase version, but this doesn't matter here) with the VisualEditor. I got the error message "Error contacting the Parsoid/RESTBase server (HTTP 400)" when loading a page with the VE.

However I think I made a little progress on this front and maybe this is of help for others:

When adding the line

$wgVisualEditorFullRestbaseURL = "< public-url with protocol >/w/rest.php/<domain>/";

to LocalSettings.php I was able to send the request through the proxy. However this caused the issue that now all of the calls in the log appeared with "/v1/" instead of "/v3/" in the URL (seems like a bug from a previous version), so I made a quick and dirty fix by adding

RewriteRule ^(.*)/v1/(.*)$ /w/$1/v3/$2 [R=301,QSA]

to the .htaccess file (this could probably be improved a bit, but it worked for me for this moment. If you want to make this persistent, add echo "RewriteRule ^(.*)/v1/(.*)$ /w/\$1/v3/\$2 [R=301,QSA]" >> /var/www/html/.htaccess to entrypoint.sh in the docker setup).

So the VisualEditor now loads the content it is supposed to edit.

However, it is still not possible to save these changes, because then the same error message appears again: Error contacting the Parsoid/RESTBase server (HTTP 400)

I give up for now, but I wanted to share my little progress here nonetheless, maybe this is of help for some of you out there struggling with the same issue. I don't know enough about the internal workings of Parsoid and RESTBase, to have a proper understanding of what might cause this issue.

CharlesNepote (talkcontribs)
24.232.179.239 (talkcontribs)

you only need to set the public IP of the host running the containered mediawiki into the /etc/hosts file of that instance pointing to the URL that you are using as $wgCanonicalServer (or $wgServer). You can do this by defining a new Dockerfile from the latest stable mediawiki, setting an entrypoint to execute some bash that after it does what you need runs "exec apache2-foreground" (the actual CMD that runs the original mediawiki Dockerfile)

The bash you need is something like

DEST_IP=$(curl -sL ipconfig.me)

echo "${DEST_IP} your_url_defined_for_$wgServer" >> /etc/hosts

24.232.179.239 (talkcontribs)

sorry I think it's better if you use 172.17.0.1 as the ip address configured on /etc/host at the docker instance pointing to your MW URL, so your bash could be as follow:

entry.sh

#!/bin/bash

echo "172.17.0.1 your_url_defined_for_$wgServer" >> /etc/hosts

exec apache2-foreground


and your Dockerfile like:

FROM mediawiki

COPY entry.sh /usr/bin

ENTRYPOINT /usr/bin/entry.sh

Sc84647 (talkcontribs)

Make sure you're explicitly loading the Parsoid extension if you're setting $wgVirtualRestConfig - I lost days figuring out why my 'zeroconfig' docker setup with VisualEditor wasn't working as expected.

In my LocalSettings.php I've set the $wgCanonicalServer URL to localhost (http, port 80), $wgServer URL to my docker hostname (http, port 8080), defined 'url' in $wgVirtualRestConfig as recommended in Extension:VisualEditor#Setting up VisualEditor and also defined 'domain' as my docker hostname, and added:

wfLoadExtension( 'Parsoid', 'vendor/wikimedia/parsoid/extension.json' );

(Apologies for the convoluted way of describing those the three URLs - the abuse filter won't let me post the actual URLs here)

2600:1700:7412:950F:D4DF:3729:E49A:7DD2 (talkcontribs)

I am having the same issue. I followed Sc84647's recommendations but to no avail. This is supposed to be zero config, and hoo-boy there's a lot of configuration and trial and error. I have an nginx reverse proxy. I can't seem to get Visual Editor to work no matter what I do.

180.252.121.79 (talkcontribs)

I have similar issue too, I use latest master repo. MediaWiki loads just fine under intranet, but when I access it from outside via our SSL proxy, the javascript breaks and I'm not sure how to fix it.

Reply to "Mediawiki 1.35.1 and VisualEditor behind a proxy not working"