Handle properly the '/https/*' urls
authorChristophe de Vienne <christophe@unlish.com>
Tue, 02 Sep 2014 20:50:33 +0200
changeset 11505 eca6387f5b87
parent 11504 8701caf9edf0
child 11506 bfc1aa1dba30
Handle properly the '/https/*' urls CW uses a url prefix to detect https behing a reverse-proxy. A more proper way to do that is documented here in the waitress documentation (waitress is the default pyramid wsgi server): https://waitress.readthedocs.org/en/latest/#using-behind-a-reverse-proxy A later version should implement this, or use waitress in the 'pyramid' command. Related to #4291181
pyramid_cubicweb/bwcompat.py
--- a/pyramid_cubicweb/bwcompat.py	Tue Sep 02 20:49:57 2014 +0200
+++ b/pyramid_cubicweb/bwcompat.py	Tue Sep 02 20:50:33 2014 +0200
@@ -114,6 +114,10 @@
         self.cwhandler = registry['cubicweb.handler']
 
     def __call__(self, request):
+        if request.path.startswith('/https/'):
+            request.environ['PATH_INFO'] = request.environ['PATH_INFO'][6:]
+            assert not request.path.startswith('/https/')
+            request.scheme = 'https'
         try:
             response = self.handler(request)
         except httpexceptions.HTTPNotFound: