How to use django-sslify to force https on my Django+nginx+gunicorn web app, and rely on Cloudflare's new free SSL? -


INTRODUCTION

Now, and I will not be fooled to take advantage of it on my site, and To break everything in the process of trying a downright dickhead,

I can fix code apps, but when installing or configuring https / nginx / gunicorn / etc / idon'tknowtheterminology So, I know enough to follow the Googled instructions.

Question

I would like to use the DJGengo-SSLFiage to force https on my DNS web app.

known facts

  1. how can I do this
    1. How do I get balance without balancing my life? Can i do 1.7, is running on a digital osian server, which has reached a (free) cloud flare DNS. (Service?)
    2. Manually access my site to default in the headers.
    3. Manually switch to green lock and work with everyone, but it breaks all form submissions error "(403) CSRF verification failed. The request has been canceled."
    4. In my cloud-flares site settings, the domain is currently configured for "Flexible SSL".
    5. Django breaks everything with my current setup firmly, and is unable to return the browser response.
    6. Tells me that I should use the "full SSL" configuration setting when using django-sslify with cloud-flare SSL. / Li>
    7. Due to hesitation, where it has been mentioned that a $ 20 / mo Pro Cloudflare account is required to control SSL termination, I do not really want to screw it: /
    8. There was only 1 instance of "http" or "https" in my NGNX and Gnocornian configurations, especially in my NGN config:

    location / { Proxy_pass http://127.0.0.1:8001; ...}

    OK I think I have all

    In addition, my server is a Django Rest Framework API for a phonegap app Provides, should it be kept in mind? Let me know if I need to provide additional information and I'll be back to you. Thanks for taking a look at this! :)

CloudFlare allows you to enable specific, one of which is applicable to SSL (by) To do. Additionally, the good thing is to use addition django-sslify or django-secure


To establish SSL redirect, you also need to handle Jango's secure requests. Fortunately, to do this, but there are some things that it is not mentioned but I have had to do with NGNX.

In your DNS settings, how do you find a secure request for Django

  SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')  

In your nginx configuration, you need to set up the X-Forward-Protocol header (and for X-forwarded-for- / X -skem headers are also useful).

  Proxy_Set_Header X-Scheme $ Scheme; Proxy_set_header ex-forward-protocol $ scheme; Proxy_set_header X-Forward- $ proxy_add_x_forwarded_for;  

You need a proxy below header, so Django is able to read the correct host and port, which is used to create full URL and CSRF , Among other things

  proxy_set_header host $ http_host;  

Note that I have $ http_host instead of $ host_port $ host_port or $ host: $ server_port is the variable used. This will ensure that the DEGENGO still respect CSRF requests on non-standard ports, while still giving you the correct absolute URL.

With most things related to NGNX and Goncorn, YMMV and it becomes easier after you many times.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -