Report this

What is the reason for this report?

Nginx SSL on Django admin site

Posted on November 2, 2014
pope

By pope

Hello,

Droplet: Ubuntu Django on 14.04

I want to configure Nginx to serve the admin portion of my Django site over SSL but not the rest of the site. The admin features are at example.com/admin/*. Is there a way to just serve this location over SSL?

Thanks!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Yes, basically what you do is make it redirect the URL when you’re accessing /admin, something like this:

location /admin {
    return 301 https://$server_name$request_uri;
}

Then you have a server-block which will handle all the SSL-requests, basically the same as your other server-block for non-SSL traffic, but only listening on SSL. If you choose to combine the two server-blocks into one you have to check every request with an if-statement, which is not recommended.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.