Page MenuHomePhabricator

VisualEditor can edit, but not save pages, if $wgServer is a protocol-relative URL on a secure site: "Error contacting the Parsoid/RESTBase server (HTTP 415)"
Open, Needs TriagePublicBUG REPORT


List of steps to reproduce (step by step, including full links if applicable):

  • Create a plain vanilla MediaWiki site with HTTPS
  • In LocalSettings.php, set $wgServer using a protocol-relative URL, such as $wgServer = '//';
  • Confirm that the wiki can edit and save pages.
  • Install VisualEditor and load it in LocalSettings.php like so: wfLoadExtensions(array('VisualEditor'));
  • Click "Edit" to edit a page with VisualEditor. This should work fine.
  • Type some text on the page you are editing. This should work fine
  • Attempt to save the edited page. The save fails with the error: Error contacting the Parsoid/RESTBase server (HTTP 415)
  • Now, in LocalSettings.php, set $wgServer to use an explicit https URL, such as $wgServer = '';
  • Edit and save a page using VisualEditor. It should work fine.

What happens?:
When $wgServer is protocol-relative, a dialog appears, Error contacting the Parsoid/RESTBase server (HTTP 415)

What should have happened instead?:
VisualEditor should save pages correctly.

Note: The problem does not occur on an HTTP (non-secure) site. VisualEditor saves pages correctly if $wgServer is protocol-relative.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
MediaWiki 1.37.1
VisualEditor 0.1.2

See ticket T268277 for early attempts to debug this problem. It was originally misidentified as a $wgGroupPermissions issue.

Relevant configuration files:

Here is my complete LocalSettings.php, sanitized:

if ( !defined( 'MEDIAWIKI' ) ) {

$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgStylePath = "$wgScriptPath/skins";
$wgServer = '//';
$wgSitename = "Test Site";
$wgArticlePath = "/notes/$1";

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "wikidb";
$wgDBuser = "wikiuser";
$wgDBpassword = "password here";
$wgDBprefix = "wp_";
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
$wgDBmysql5 = true;

# Secret keys
$wgSecretKey = "1234567890123456789012345678900987654321123123123123123123123123";
$wgUpgradeKey = "1234567890987654";

# VisualEditor
$wgDefaultSkin = "vector";

Here is the Apache config:

<IfModule mod_ssl.c>
<VirtualHost *:443>

    # Index file and Document Root (where the public files are located)
    DirectoryIndex index.html index.php
    DocumentRoot /var/www/
    # Log file locations
    LogLevel warn
    ErrorLog  /var/www/
    CustomLog /var/www/ combined

    # Root redirect
    RedirectMatch ^/$

    ServerAlias *
    ServerAlias *

    SSLCertificateFile /etc/letsencrypt/live/
    SSLCertificateKeyFile /etc/letsencrypt/live/
    Include /etc/letsencrypt/options-ssl-apache.conf

<Directory "/var/www/">
    AllowOverride None
    RewriteEngine On
    RewriteRule ^/?notes(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
    RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

<Directory "/var/www/">
    # Ignore .htaccess files
    AllowOverride None

    # Serve HTML as plaintext, don't execute SHTML
    AddType text/plain .html .htm .shtml .php .phtml .php5

    # Don't run arbitrary PHP code.
    php_admin_flag engine off

Event Timeline

It would be interesting to determine whether the same can be reproduced when using Nginx as the webserver.

Does it work if $wgServer is a protocol-relative URL, but you also have set $wgCanonicalServer to an absolute URL?

@matmarex : Yes, setting $wgCanonicalServer as follows makes VisualEditor work:

$wgServer = '//';
$wgCanonicalServer = 'https:' . $wgServer;

In case this helps: setting $wgForceHTTPS does not make VisualEditor work:

$wgServer = '//';
$wgForceHTTPS = true;                    // does not help