Jump to content

Nginx HTTP Authentification


ytzelf

Recommended Posts

Hello everyone,

 

I am trying to get nginx basic http to work with emby but am getting some errors with http headers

 

I added the following lines to my nginx configuration

proxy_set_header               Authorization           $http_authorization;
proxy_pass_header              Authorization;

Which seems to work in some cases (from nginx debug log)

2015/10/19 23:30:05 [debug] 8860#0: *7 http proxy header:
"GET /emby/web/dashboard.html HTTP/1.1
X-Real-IP: xxxxxxxx
X-Forwarded-Host: xxxxxxxx
X-Forwarded-For: xxxxxxxx
X-Forwarded-Proto: xxxxxxxx
X-Forwarded-Protocol: https
Connection: upgrade
Host: 127.0.0.1:8096
Authorization: Basic xxxxxxxxxxxxxxxxxxxxx
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Linux; Android 5.1.1; XT1039 Build/LMY48W) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$
DNT: 1
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,fr;q=0.6
Cookie: _pk_id.1.460e=ddfc4db714572eee.1445258016.2.1445261772.1445261758.; wanted_view=thumb; snatched_view=list;$

But fails elsewhere

2015/10/19 23:30:01 [debug] 8860#0: *7 HTTP/1.1 401 Unauthorized
Server: nginx/1.6.2
Date: Mon, 19 Oct 2015 21:30:01 GMT
Content-Type: text/html
Content-Length: 596
Connection: keep-alive
WWW-Authenticate: Basic realm="Restricted"
Resulting in a 401 error each time I try to watch a video online (right after clicking on the play button, everything else works just fine).
 
I was just wondering where exactly I would have to make some changes for all requests to include the Autorization header.
 
Disabling http authentification altogether makes everything fine.
 
Thanks a lot !
 
 
Edited by ytzelf
Link to comment
Share on other sites

  • 1 month later...

I'm trying to do this same setup. I've seen that if I enable the authorization passage, I will be prompted for the username and password multiple times. (as many as 5.) Once this weird multiple authorization is done, everything seems to work from there.

Link to comment
Share on other sites

Hi, I use nginx as a reverse proxy as well.

I don't usually use the nginx authentication since there are users in emby.

I tried to add the auth in nginx in my configuration and it works, here's the conf:

   location /emby {
       proxy_pass http://127.0.0.1:8910;
       proxy_buffering off;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;

       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-Proto $remote_addr;
       proxy_set_header X-Forwarded-Protocol $scheme;
       proxy_redirect off;


       auth_basic "Restricted";
       auth_basic_user_file /etc/nginx/.htpasswd;

       proxy_set_header Connection "upgrade";
   }

You have to change your emby port and the htpasswd file location, of course.

Give it a try and let me know  :)

 

Bonfi

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...