From 887975c3f33a4af2d16a083f657e76bb58148ff1 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 14 Oct 2016 16:46:19 +0200 Subject: [PATCH] library/roles/ckan: Modify the wsgi configuration to pass the correct http protocol headers to the application. d4science-ghn-cluster: ckan, fix the nginx templates and cleanup some of the tasks. --- ckan/ckan/tasks/ckan.yml | 5 +++++ ckan/ckan/templates/apache.wsgi.j2 | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 ckan/ckan/templates/apache.wsgi.j2 diff --git a/ckan/ckan/tasks/ckan.yml b/ckan/ckan/tasks/ckan.yml index c42bd6cd..3f0e6440 100644 --- a/ckan/ckan/tasks/ckan.yml +++ b/ckan/ckan/tasks/ckan.yml @@ -14,6 +14,11 @@ notify: Restart CKAN tags: [ 'ckan', 'ckan_ini' ] +- name: Install the apache.wsgi + template: src=apache.wsgi.j2 dest={{ ckan_confdir }}/apache.wsgi + notify: Restart CKAN + tags: [ 'ckan', 'apache' ] + - name: Create the base directory for the CKAN file storage file: dest={{ ckan_file_storage_dir }} state=directory owner={{ apache_user }} group={{ ckan_shell_user }} mode=2770 tags: ckan diff --git a/ckan/ckan/templates/apache.wsgi.j2 b/ckan/ckan/templates/apache.wsgi.j2 new file mode 100644 index 00000000..4418d33f --- /dev/null +++ b/ckan/ckan/templates/apache.wsgi.j2 @@ -0,0 +1,14 @@ +import os +activate_this = os.path.join('/usr/lib/ckan/default/bin/activate_this.py') +execfile(activate_this, dict(__file__=activate_this)) + +from paste.deploy import loadapp + +config_filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'production.ini') +from paste.script.util.logging_config import fileConfig +fileConfig(config_filepath) +_application = loadapp('config:%s' % config_filepath) + +def application(environ, start_response): + environ['wsgi.url_scheme'] = environ.get('HTTP_X_URL_SCHEME', 'http') + return _application(environ, start_response)