title: Trouble with ProxyPass of REMOTE_USER from nginx to Django
body: <p>I have an nginx web server that's configured with client certificate authentication. Once authenticated, I proxy requests to a uWSGI Django application server. I've set-up my Django application to perform authentication using REMOTE_USER (<a href="https://docs.djangoproject.com/en/3.1/howto/auth-remote-user/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/3.1/howto/auth-remote-user/</a>), however it doesn't seem to be working as I receive the &quot;'AnonymousUser' object is not iterable&quot; error from Django.</p>
  <p>I'm assuming that I'm missing something in my nginx configuration:</p>
  <pre><code>server {
    listen 80;
    server_name my.website.net;
    return 301 https://$server_name$request_uri;
  }
  server {
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/my.website.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my.website.net/privkey.pem;
    ssl_verify_client on;
    ssl_verify_depth 2;
    ssl_client_certificate /etc/nginx/ssl/cas.pem;
    proxy_set_header X-SSL-Client-Serial $ssl_client_serial;
    proxy_set_header X-SSL-Client-Verify $ssl_client_verify;
    proxy_set_header X-SSL-Client-S-DN   $ssl_client_s_dn;
    proxy_set_header X-Remote-User $remote_user;
    proxy_set_header REMOTE_USER $remote_user;
  
    location / {
      root /var/www/my.website.net;
      index index.html index.htm;
    }
  
    location /django {
      proxy_set_header Host 10.101.10.228;
      proxy_http_version 1.1;
      proxy_set_header Connection &quot;Keep-Alive&quot;;
      proxy_set_header Proxy-Connection &quot;Keep-Alive&quot;;
  
      proxy_pass http://10.101.10.228:8000/webapp;
      proxy_redirect http://10.101.10.228/django/ https://my.website.net/django/;
  
    }
  
  }
  </code></pre>
  <p>I've also tried utilizing the nginx uwsgi_* directives with no luck:</p>
  <pre><code>upstream django {
    server 10.101.10.228:8000;
  }
  location /django {
    include         uwsgi_params;
    uwsgi_pass django;
    uwsgi_param SCRIPT_NAME /webapp;
    uwsgi_param REMOTE_USER $remote_user;
    uwsgi_param X-REMOTE-USER $remote_user;
  }
  </code></pre>
  <p>Is there something that appears to be missing?</p>