I've been running MediaWiki with Wikibase, the Wikidata Query Service (GitHub), and the Wikidata Query Service GUI on a remote Ubuntu server. I am tunneling into that server in order to access things on my local machine.
The GUI (running at localhost:8080 on the server, localhost:600 on the local machine) is attempting to contact the Query Service, specifically Blazegraph, which is running via a Jetty server (localhost:9999 on both server and local machine).
Everything works in terms of separate components (successful installations, no errors), and if a SPARQL query is entered in the Blazegraph UI or taken and copy-pasted into the browser, the correct RDF output is produced. However, if the query is run from the Wikidata Query Service GUI, it produces a net::ERR_FAILED 200
and:
Access to XMLHttpRequest at 'http://localhost:9999/bigdata/sparql' from origin 'http://localhost:600' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The Wikidata Query Service GUI is run using npm start
, which in turn runs http-server --cors='*'
. The Blazegraph at localhost:9999
is run using:
sudo BLAZEGRAPH_OPTS="-DwikibaseConceptUri=http://localhost:400" bash /var/lib/mediawiki/extensions/wikidata-query-rdf/dist/target/service-0.3.111-SNAPSHOT/runBlazegraph.sh
I'm not sure exactly how to go about allowing the Wikidata Query Service GUI to access the Wikidata Query Service, so any help would be much appreciated!
UPDATE 1: It might be helpful to say that this is with Jetty 9?
I finally figured it out, by adding a proxy into /etc/apache2/sites-enabled/000-default.conf
, as follows:
<VirtualHost *:9000>
Header add Access-Control-Allow-Origin "*"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:9999/
ProxyPassReverse / http://127.0.0.1:9999/
</VirtualHost>
This then listens for the call from localhost:8080->localhost:9000, and redirects the call to localhost:9999. I also added a bit more information to a related Phabricator page.