5

I set up a Django server on port 8011, and have a nginx serving it as a subdirectory on port 80.

Static files, good.

Pages, good.

But when I access /subdirectory/admin/, it takes me to: /admin/login/?next=/admin/

Which is of course a 404 error, but if I access /subdirectory/admin/login/?next=/admin/, it works fine.

Any ideas? Do I need to set a variable in the settings.py?

urls.py:

    url(r'^admin/', admin.site.urls),

nginx config:

server {
    listen 80;

    location /sdc {
        proxy_pass http://127.0.0.1:8011/;
    }
}
Gray Adams
  • 3,927
  • 8
  • 32
  • 39

1 Answers1

-3

I believe what is happening is that when django sees you aren't logged in, it redirects you to the url named 'admin:login'. It figures out that url by reversing what it sees in your urls.py, which is this case comes out to be admin/login/ (https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#reversing-admin-urls). This means it doesn't know it is operating within /subdirectory/.

Try add subdirectory in urls.py

url(r'^subdirectory/admin/', admin.site.urls),
VMatić
  • 996
  • 2
  • 10
  • 18