1

It seems to me that I do not quite understand the REMOTE_USER variable. I have three instances based on different hosts: nginx, django_auth_server, django_app_server. I am trying to implement "single sign on": the user logs on to the django_auth_server via nginx, is redirected to the django_app_server and continues surfing without authentication. In my case after redirection to the root folder (from '/login' to '/') the REMOTE_USER variable is empty. But it does exists in the request headers:

Content-Type: text/html; charset=utf-8
Location: /
REMOTE_USER: alfabeta
X-Frame-Options: SAMEORIGIN
Vary: Cookie
Content-Length: 0
Set-Cookie:  csrftoken=...
Set-Cookie:  sessionid=...

Code from the authorization view (djangoauth instance):

        if user is not None:
            login(request, user)
            r = redirect('/')
            r['REMOTE_USER'] = username
            return r

I'm not sure if it is correct to set the variable in this way.

part of the nginx config

server {
  listen 8080 default_server; 
  server_name localhost;
  charset     utf8;
  autoindex   off;

  underscores_in_headers on;
  proxy_pass_request_headers on;
  ...
  location / {
    include /etc/nginx/uwsgi_params;
    uwsgi_pass uwsgiapp;
    uwsgi_read_timeout 300;

    uwsgi_param Host $host;
    uwsgi_param X-Real-IP $remote_addr;
    uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
    uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;

  }

  location =/login/ {
    include /etc/nginx/uwsgi_params;
    uwsgi_pass uwsgiauth;
    uwsgi_read_timeout 300;

    uwsgi_param Host $host;
    uwsgi_param X-Real-IP $remote_addr;
    uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
    uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;

    uwsgi_param REMOTE_USER $remote_user;
  }

How to pass the variable to the application server?

Ilya
  • 11
  • 1
  • 3

0 Answers0