When you send a request to the site that is behind basic authentication, the client (browser) sends the "Authorization" header (as follows - see "Basic access authentication" on Wikipedia).
Ngnix passes it to your application.
Django Rest Framework also supports: BasicAuthentication, and it is enabled by default.
REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', ) }
source: http://www.django-rest-framework.org/api-guide/authentication/
So, django-rest-framework sees the "Authorization" heading and thinks that it should be a django user with a password.
If such a user does not exist, you have received: "HTTP 401 Unauthorized". See: http://www.django-rest-framework.org/api-guide/authentication/#basicauthentication
Soultions
Choose one: a) Add ngnix to your site configuration
location / { ... proxy_set_header Authorization ""; ... }
therefore, DRF will not get the "Authorization" header, so it will not try to map the django user.
After this change - basic auth cannot be used on the django side (empty header!
b) Get rid of "rest_framework.authentication.BasicAuthentication" from REST_FRAMEWORK (in django settings).
If not defined, add django settings:
REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.SessionAuthentication', ) }
Probably the best solution.
c) Use your django user / password for basic auth?
Realy? - Do not!