Question

Nginx SSL on Django admin site

  • Posted on November 2, 2014
  • popeAsked 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!


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.