Search code examples
pythondjangoapachewsgidjango-wsgi

How do I make Django admin URLs accessible to localhost only?


What is the simplest way to make Django /admin/ urls accessible to localhost only?

Options I have thought of:

  • Seperate the admin site out of the project (somehow) and run as a different virtual host (in Apache2)
  • Use a proxy in front of the hosting (Apache2) web server
  • Restrict the URL in Apache within WSGI somehow.

Is there a standard approach?

Thanks!


Solution

  • Id go for apache configuration:

    <Location /admin>
        Order Deny, Allow
        Deny from all
        Allow from 127.0.0.1
    </Location>
    

    HTH.