Jump to content

Topic on Extension talk:VisualEditor/Flow

Nginx configuration

51
000Tom0000 (talkcontribs)
Costas Athan (talkcontribs)
This post was hidden by Costas Athan (history)
000Tom0000 (talkcontribs)

I've fixed it on NGINX by adding following to my configuration

   location /rest.php {
       try_files $uri $uri/ /rest.php?$args;
   }

Costas Athan (talkcontribs)

The server's configuration or the LocalSettings.php file?

000Tom0000 (talkcontribs)

Servers configuration. The error seemed to be that my pretty url rewrite wrongly send it to index.php instead of rest.php.

Morikurayami (talkcontribs)

Oh my gah!! I can't thank you enough. I just copied and pasted and voilà, it work pretty straight and flawlessly!!

This post was hidden by Costas Athan (history)
D3nnis3n (talkcontribs)

I got the same issue and the nginx configuration Tom mentioned does not help either.

Costas Athan (talkcontribs)

Because it's possible that there are multiple causes for the 404 error.

D3nnis3n (talkcontribs)

So, i found out that VisualEditor does show and work when trying to create a page that does not yet exist - but it fails when trying to edit a page that exists.

Costas Athan (talkcontribs)

You are right! It's the same for me.

D3nnis3n (talkcontribs)

I tried around for hours, but couldn't find a solution. Hopefully someone that has one will read this and help us out.

Maybe reporting a bug on their bugtracker would be useful, but it needs a registration, which i don't really want to do.

Costas Athan (talkcontribs)
D3nnis3n (talkcontribs)

Thats a different issue, though. They got the issue on saving. We don't even get that far out-of-the-box. Also looks like an issue for an older beta version and being on hold as well.

Lostraven (talkcontribs)

Did you ever find a solution, 10 months later? Having the same problem on 1.36.1.

110.33.200.115 (talkcontribs)

I can replicate that VisualEditor does show and work when trying to create a page that does not yet exist - but it fails when trying to edit a page that exists.

This post was hidden by Costas Athan (history)
Scripcat (talkcontribs)

I'm able to reproduce the same error on a new installation. Perhaps there's something with the php version of parsoid that needs to be configured?

D3nnis3n (talkcontribs)

Manually configuring

    $wgVisualEditorRestbaseURL = "https://example.com/api/rest_v1/page/html/";

    $wgVisualEditorFullRestbaseURL = "https://example.com/api/rest_";

for the main wiki and all the other wikis of the wiki family (we're using them in subfolders /en, /de, etc.) made the Visual Editor actually open without that error.

But it still doesn't show the pages content and is loading infinitely.

Costas Athan (talkcontribs)

Does RESTbase come with MediaWiki 1.35 or should it be installed following these directions: RESTBase/Installation?

D3nnis3n (talkcontribs)

I did not install a RestBASE Installation, i just changed these URLs.

The Visual Editor is supposed to work out-of-the-box and i can't find instructions for specific installs required.

Costas Athan (talkcontribs)
Costas Athan (talkcontribs)
LapisLazuli33 (talkcontribs)

VisualEditor/PHP will contact wiki/rest.php or w/rest.php when you go into visual editing. If you are already using rewrites to make nice short URLs, you may find that - your rewrite rule will make the call to rest.php redirect to index.php, which gives a 404.

If you just ignore redirecting call to rest.php, your visual editor will work but cannot load page contents - it is accessing rest.php/yourdomain.name/v3/.... to load the page content, which cannot be ignored by checking rest.php.

The solution is, check the HTTP_USER_AGENT - VisualEditor make its access with UA: VisualEditor-MediaWiki/1.35.0. Add the bold line to every rewrite rules you defined for mediawiki (I'm assuming using apache2, tweak this accordingly if you are using other service):

RewriteCond %{REQUEST_URI} !^(static)

RewriteCond %{HTTP_USER_AGENT} !^(VisualEditor)

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d

RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/wiki/index.php [L]

This will not make any rewrite to calls from VisualEditor and make it successfully access page contents and load it without affect other short URLs.

No other modification in LocalSettings.php, My env: Ubuntu 18.04 + PHP7.4 + Apache2

Junebug12851 (talkcontribs)

You provide a great explanation but what do I do if I'm using NGINX.

Nnyby (talkcontribs)

@Junebug12851 if you're using nginx, something like this works:


    location @rewrite {

        if ($http_user_agent !~* "^VisualEditor$") {

            rewrite ^/(.*)$ /index.php?title=$1&$args;

        }

    }

154.17.24.21 (talkcontribs)

I have the same issues and Tom's solution doesn't works for me as well.

D3nnis3n (talkcontribs)
Scripcat (talkcontribs)

I adding this gets me somewhere:

// Parsoid Setting $wgEnableRestAPI = true; $wgParsoidSettings = [ 'useSelser' => true, 'rtTestMode' => false, 'linting' => true, ]; // Restbase server Setting $wgVirtualRestConfig['modules']['restbase'] = [ 'url' => 'localhost:/rest.php', 'domain' => 'localhost' ]; $wgVisualEditorRestbaseURL = "HTTPS://YOUR_DOMAIN/api/rest_v1/page/html/"; $wgVisualEditorFullRestbaseURL = "HTTPS://YOUR_DOMAIN/api/rest_"; // Parsoid Setting $wgParsoidSettings = [ 'linting' => true, '_merge_strategy' => 'array_plus', ]; wfLoadExtension( 'Parsoid', "$IP/vendor/wikimedia/parsoid/extension.json" ); wfLoadExtension( 'VisualEditor' );

D3nnis3n (talkcontribs)

So this works for you?

Scripcat (talkcontribs)

No. I got too excited. It loads without an error message and it looks fine until you realize it hasn't loaded the actual page's contents. Trying to save any edits will then result in cURL 28 error.

LapisLazuli33 (talkcontribs)

VisualEditor/PHP will contact wiki/rest.php or w/rest.php when you go into visual editing. If you are already using rewrites to make nice short URLs, you may find that - your rewrite rule will make the call to rest.php redirect to index.php, which gives a 404.

If you just ignore redirecting call to rest.php, your visual editor will work but cannot load page contents - it is accessing rest.php/yourdomain.name/v3/.... to load the page content, which cannot be ignored by checking rest.php.

The solution is, check the HTTP_USER_AGENT - VisualEditor make its access with UA: VisualEditor-MediaWiki/1.35.0. Add the bold line to every rewrite rules you defined for mediawiki (I'm assuming you are using apache2, tweak this accordingly if you are using other service):

RewriteCond %{REQUEST_URI} !^(static)

RewriteCond %{HTTP_USER_AGENT} !^(VisualEditor)

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d

RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/wiki/index.php [L]

This will not make any rewrite to calls from VisualEditor and make it successfully access page contents and load it without affect other short URLs.

No other modification in LocalSettings.php, My env: Ubuntu 18.04 + PHP7.4 + Apache2

Costas Athan (talkcontribs)

The same problem appears without short URLs: https://phabricator.wikimedia.org/T263928#6496623

Anyway, I personally use short URLs. I added the line you suggested in my .htaccess and now I get "Error contacting the Parsoid/RESTBase server (HTTP 403)", instead of "Error contacting the Parsoid/RESTBase server (HTTP 404)" I was getting without it.

Dloewenherz2 (talkcontribs)

The user agent conditional was the correct answer for me here. Thanks!

This post was hidden by Costas Athan (history)
95.222.50.200 (talkcontribs)

I was getting the same error message (403, not 404) with a standard, out-of-the-box MW 1.35, I'm not using any redirects/rewrite rules that I am aware of. Setting $wgVisualEditorFullRestbaseURL makes VE load, but with no content...

Since we are using a webhosting service, we are not able to edit the nginx or Apache base configuration.

95.222.50.200 (talkcontribs)

So, if I set

$wgVirtualRestConfig['modules']['parsoid'] = [

   'url' =>  .../rest.php',

   'domain' => '...',

];

I get a 404 error instead of the 403 error.

Antoine.rozenknop (talkcontribs)
location /rest.php/ {
    try_files $uri $uri/ /rest.php?$query_string;
}

worked for me, as it is written here : Parsoid

Junebug12851 (talkcontribs)

This didn't work for me, same 404 message.

Bjsdaiyu (talkcontribs)

On WM 1.35.0, with an nginx reverse proxy, having a similar issue with error "Error contacting the Parsoid/RESTBase server: http-request-error" when attempting to save VE documents, however I am not even getting a 404 and there is no activity in the NGINX error logs. Source code edits and saves are working without issue. An access to https://debian-guest.lan/rest.php suggests the redirection is correct (i.e., I receive what appears to be a response from the rest service); however https://debian-guest.lan/rest.php/v1/page/Main_Page/html (which I assume is the correct path) results in

  • messageTranslations: {
    • en: "Unable to fetch Parsoid HTML" },
  • httpCode: 500,
  • httpReason: "Internal Server Error"

One other datapoint: when I create a new page, for the first time, the entire process succeeds using VE through saving and everything. I immediately encounter problems as described above when I attempt to edit the existing page via VE.

One final datapoint: interestingly, when I disable https, everything works exactly as it should with rewrite rules otherwise untouched. Final update, this was due to not setting up the RootCA in the test VM; once that was done everything (finally) works in HTTPS. Leaving this here for future reference by others in case they need minimally working server/LocalSetting configuration.


full (this is a test VM) nginx and LocalSettings.php configs are available at the Pastebin links. Same behavior with with/out the trailing slash in "location /rest.php/" and with "rest.php?$query_string" instead of "rest.php?$args"

Aron Manning (talkcontribs)

If anyone still struggles with VE 404 error on fresh install (1.36-alpha in my case):

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

in LocalSettings.php solved it. Wouldn't call this zero config.

Should be noted that for a brief time period (a few weeks - 2 months) this worked without configuration in 1.35-alpha and broke later.

Jahoti (talkcontribs)

I was able to get my VisualEditor 404s to go away by following a config similar to what 000Tom0000 posted earlier (and is also given on Parsoid#Development ). My setup: I'm using Nginx, MediaWiki 1.35, and I was receiving HTTP 404s on rest.php/* only on https and not http only.

Since my wiki was using a $wgScriptPath (e.g. site), my Nginx config was:

location /site/rest.php/ {

    try_files $uri $uri/ /site/rest.php?$query_string;

}

109.9.182.128 (talkcontribs)

Same here


Additional conf in nginx resolved the problem


location /rest.php {

try_files $uri $uri/ /rest.php?$args;

}

109.9.182.128 (talkcontribs)

Edit .

with

try_files $uri $uri/ /rest.php?$args;

I can load visual editor, but not the content of the page


with

try_files $uri $uri/ /site/rest.php?$query_string;

I have no 404 error, but 400 instead

109.9.182.128 (talkcontribs)

In the end nothing mentionned here resolved the problem

171.97.48.45 (talkcontribs)

I solved by adding the following configuration:


location ~ /rest.php {

try_files $uri $uri/ /rest.php?$args;

}

68.145.238.178 (talkcontribs)

Running Ubuntu Server 20.04, MediaWiki 1.36.1, fresh install VisualEditor error, struggled with problem for couple weeks. Seems MediaWiki out-of-the-box install tends to work better with Apache2 vs nginx. Eventually VisualEditor worked, without errors, by installing additional php components as follows:


sudo apt install php7.4-mbstring php7.4-xml php7.4-fpm php7.4-json php7.4-mysql php7.4-curl php7.4-intl php7.4-gd php7.4-mbstring texlive imagemagick

71.235.161.204 (talkcontribs)

I installed all of the modules in this list I was missing and it didn't resolve the issue on my implementation... really a shame, can't deploy this server without a working visual editor.

207.23.128.10 (talkcontribs)

I use mw 1.37.1 container image and behind the nginx. My visual editor always got

Error contacting the Parsoid/RESTBase server: (curl error: 6) Couldn't resolve host name

By clicking "Reply", you agree to our Terms of Use and agree to irrevocably release your text under the CC BY-SA 4.0 License and GFDL.