mezzanine.core.middleware.SSLRedirectMiddleware Depricated 1600?

91 views
Skip to first unread message

Akhlaq Rao

unread,
Oct 13, 2016, 12:55:43 AM10/13/16
to Mezzanine Users
If it's deprecated then how do we enable SSL now? when I enable it I get the following error:

unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10ff97950>
Traceback (most recent call last):
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/mezzanine/core/management/commands/runserver.py", line 163, in inner_run
    super(Command, self).inner_run(*args, **kwargs)
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 142, in inner_run
    handler = self.get_handler(*args, **options)
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/mezzanine/core/management/commands/runserver.py", line 166, in get_handler
    handler = super(Command, self).get_handler(*args, **options)
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
    handler = super(Command, self).get_handler(*args, **options)
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
    return get_internal_wsgi_application()
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 46, in get_internal_wsgi_application
    return get_wsgi_application()
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
    return WSGIHandler()
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
    self.load_middleware()
  File "/Users/kashfey/Documents/Kash/Development/Webservice/mezzanine/couture92/lib/python3.5/site-packages/django/core/handlers/base.py", line 58, in load_middleware
    mw_instance = mw_class()
TypeError: __init__() missing 1 required positional argument: 'get_response'

Ryne Everett

unread,
Oct 13, 2016, 10:44:53 AM10/13/16
to Mezzanine Users
Whoops. I just pushed a fix for that bug.

However, you still shouldn't be using that middleware. If you're going to use an SSL middleware, use django's (https://docs.djangoproject.com/en/1.10/ref/middleware/#module-django.middleware.security). However, my recommendation is to handle the redirect in the frontend server (nginx, apache, etc) instead.

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Akhlaq Rao

unread,
Oct 13, 2016, 11:18:55 AM10/13/16
to mezzani...@googlegroups.com
Hi Ryne,

I totally get it, but if I do not use SSLRedirectMiddleware then I don't see SSL Enable form in the Admin Settings. Do you know how do I enable SSL without using SSLRedirectMiddleware? if I go to my frontend nginx all the SSL related entries are commented out.

server {

    listen 80;
    # listen 443 ssl;
    client_max_body_size 10M;
    keepalive_timeout    15;
    error_log /home/admin/logs/couture92_error_nginx.log info;

    # ssl_certificate      conf/couture92.crt;
    # ssl_certificate_key  conf/couture92.key;
    # ssl_session_cache    shared:SSL:10m;
    # ssl_session_timeout  10m;


Thanks, your help much appreciated.



To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.

Ryne Everett

unread,
Oct 13, 2016, 11:24:04 AM10/13/16
to Mezzanine Users
SSLRedirectMiddleware would not solve that problem, all it does is redirect to https.

The way I handle this is having a line like ` return 301 https://$host$request_uri; ` in my server block listening on port 80, and another server block listening on port 443 that actually proxies to django.

Akhlaq Rao

unread,
Oct 13, 2016, 11:33:42 AM10/13/16
to mezzani...@googlegroups.com
ok so nginx template for SSL entries no good anymore, were they directly connected to SSLRedirectMiddleWare?

Thanks,
A



To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.

Ryne Everett

unread,
Oct 13, 2016, 11:47:37 AM10/13/16
to Mezzanine Users
If you want your configuration to more closely resemble the default nginx template you can uncomment those ssl lines and use the django ssl middleware instead.

Akhlaq Rao

unread,
Oct 13, 2016, 11:48:57 AM10/13/16
to mezzani...@googlegroups.com
oh ok got you.

Thanks



To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages