Smalyshev has uploaded a new change for review.
https://gerrit.wikimedia.org/r/243883
Change subject: Allow SPARQL endpoint to be queries via POST
......................................................................
Allow SPARQL endpoint to be queries via POST
Bug: T112151
Change-Id: If7ffe591ec48a0b7cbf43469b114f140f5cfb7a9
---
M hieradata/labs/wikidata-query/common.yaml
M hieradata/role/common/wdqs.yaml
M modules/wdqs/manifests/gui.pp
M modules/wdqs/templates/nginx.erb
A modules/wdqs/templates/post.lua
5 files changed, 36 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/83/243883/1
diff --git a/hieradata/labs/wikidata-query/common.yaml
b/hieradata/labs/wikidata-query/common.yaml
index afd4996..5cf2fbd 100644
--- a/hieradata/labs/wikidata-query/common.yaml
+++ b/hieradata/labs/wikidata-query/common.yaml
@@ -3,4 +3,5 @@
"wdqs::service::use_git_deploy": false
"wdqs::package_dir": '/srv/wdqs/blazegraph'
"wdqs::data_dir": '/srv/wdqs/blazegraph'
+"nginx::variant": 'extras'
diff --git a/hieradata/role/common/wdqs.yaml b/hieradata/role/common/wdqs.yaml
index 49c2c23..52f5423 100644
--- a/hieradata/role/common/wdqs.yaml
+++ b/hieradata/role/common/wdqs.yaml
@@ -4,3 +4,4 @@
- wdqs-admins
cluster: wdqs
contact_group: admins,wdqs-admins
+"nginx::variant": 'extras'
diff --git a/modules/wdqs/manifests/gui.pp b/modules/wdqs/manifests/gui.pp
index bee2d42..c78bd73 100644
--- a/modules/wdqs/manifests/gui.pp
+++ b/modules/wdqs/manifests/gui.pp
@@ -13,6 +13,13 @@
) {
::nginx::site { 'wdqs':
content => template('wdqs/nginx.erb'),
+ require => File['/etc/nginx/post.lua'],
+ }
+
+ file { '/etc/nginx/post.lua':
+ ensure => present,
+ owner => 'root',
+ content => template('wdqs/post.lua'),
}
ferm::service { 'wdqs_http':
diff --git a/modules/wdqs/templates/nginx.erb b/modules/wdqs/templates/nginx.erb
index 1aedce1..dce41f5 100644
--- a/modules/wdqs/templates/nginx.erb
+++ b/modules/wdqs/templates/nginx.erb
@@ -27,6 +27,14 @@
access_log off;
}
+ location /sparql {
+ lua_need_request_body on;
+ content_by_lua_file /etc/nginx/post.lua;
+ limit_except GET OPTIONS POST {
+ deny all;
+ }
+ }
+
location /bigdata/namespace/wdq/sparql {
proxy_pass http://localhost:9999;
diff --git a/modules/wdqs/templates/post.lua b/modules/wdqs/templates/post.lua
new file mode 100644
index 0000000..73ee961
--- /dev/null
+++ b/modules/wdqs/templates/post.lua
@@ -0,0 +1,19 @@
+-- Translates POST to GET
+if ngx.var.request_method == "POST" then
+ ngx.req.read_body()
+ local args = ngx.req.get_post_args()
+ if not args then
+ ngx.say("failed to get post args: ", err)
+ return
+ end
+ res = ngx.location.capture('/bigdata/namespace/wdq/sparql', {args = args,
method = ngx.HTTP_GET})
+ if res.status ~= ngx.HTTP_OK then
+ ngx.status = res.status
+ ngx.print(res.body)
+ ngx.exit(res.status)
+ end
+ ngx.print(res.body)
+else
+ local args = ngx.req.get_uri_args()
+ ngx.exec('/bigdata/namespace/wdq/sparl', args)
+end
--
To view, visit https://gerrit.wikimedia.org/r/243883
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If7ffe591ec48a0b7cbf43469b114f140f5cfb7a9
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Smalyshev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits