Jump to content

Nginx (one server) proxy pass to emby server (other server)


TimeWalker
Go to solution Solved by TimeWalker,

Recommended Posts

TimeWalker

Hi!

 

I've been trying to add a proxy pass on my nginx to the emby server. The key problem here is that I'm not trying to proxy pass from localhost or 127.0.0.1 but to another server in the same local network.

 

So what this means is (example):

nginx: 192.168.1.10

emby: 192.168.1.20

URL: example.ddns.net/emby

 

What I want to achieve is that when you go to example.ddns.net/emby, it connects to the nginx server on .10 and this one proxy passes to the emby server on .20

I've tried using the config that's floating around in the forums. But the only thing happening is that I get a blank page with a 404 error on nginx's error.log. Locally it also won't work when trying 192.168.110.10/emby

        location /emby {
                # Send traffic to the backend
                proxy_pass http://192.168.1.20:8096;
                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;

                # Send websocket data to the backend aswell
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

I've tried changing around with the headers and stuff but I can't manage to make it work.

Any help would be appreciated

Link to comment
Share on other sites

Guest plexman

Hi!

 

I've been trying to add a proxy pass on my nginx to the emby server. The key problem here is that I'm not trying to proxy pass from localhost or 127.0.0.1 but to another server in the same local network.

 

So what this means is (example):

nginx: 192.168.1.10

emby: 192.168.1.20

URL: example.ddns.net/emby

 

What I want to achieve is that when you go to example.ddns.net/emby, it connects to the nginx server on .10 and this one proxy passes to the emby server on .20

I've tried using the config that's floating around in the forums. But the only thing happening is that I get a blank page with a 404 error on nginx's error.log. Locally it also won't work when trying 192.168.110.10/emby

        location /emby {
                # Send traffic to the backend
                proxy_pass http://192.168.1.20:8096;
                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;

                # Send websocket data to the backend aswell
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

I've tried changing around with the headers and stuff but I can't manage to make it work.

Any help would be appreciated

 

https://emby.media/community/index.php?/topic/22889-emby-behind-a-reverse-proxy-remote-control-issue/?p=225882

Link to comment
Share on other sites

ragmanii

that all looks right with the exception of:

proxy_pass http://192.168.1.20:8096;

 

that line should be

proxy_pass http://192.168.1.20:8096/emby;

 

Also make sure your firewall rules are set up. If I remember right by default ubuntu uses UFW. you can do a quick test to see if UFW is breaking things by doing:

ufw disable

 

Just make sure you re-enable it when you are done with the quick test:

ufw enable

Link to comment
Share on other sites

TimeWalker

@@plexman

That's the one I meant with "floating around in the forums". Sadly I couldn't find a solution in the later pages because the thread drifted into apache config

 

@ragmani

The nginx server is running on a Raspberry (Debian-based) while the emby server is running on a Thecus NAS.

I edited the config to use /emby in proxy pass. I'm not sure if the NAS is doing the firewall blocking. I tried flushing and allowing everything through iptables on my nginx server but this doesn't seem to help.

Edited by TimeWalker
Link to comment
Share on other sites

pir8radio

What is in your "server" section?   What does the 404 say?  404 means the server is being reached but its unable to find whatever it thinks you are looking for...  I doubt its firewall, or you wouldnt get a webserver error code returned.    I bet your server section is pointing to something local, and bypassing proxy pass.   Post the full 404.. and your server section of the nginx config.

 

it should resemble something like: (assuming you are using the default port 80 to nginx from the web making it easy for users, otherwise replace 80 with your port)

 

server {
    listen [::]:80;
    listen 80;
    server_name example.ddns.net;
Edited by pir8radio
  • Like 1
Link to comment
Share on other sites

  • Solution
TimeWalker

Look at that! I've found my solution to the problem! :D

 

I've looked into the error.log of nginx again and saw this:

2016/10/15 11:22:16 [error] 28203#0: *5 open() "/usr/share/nginx/www/emby/web/css/all.css" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/css/all.css?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"
2016/10/15 11:22:16 [error] 28203#0: *6 open() "/usr/share/nginx/www/emby/web/scripts/site.js" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/scripts/site.js?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"
2016/10/15 11:22:16 [error] 28205#0: *7 open() "/usr/share/nginx/www/emby/web/bower_components/requirejs/require.js" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/bower_components/requirejs/require.js?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"
2016/10/15 11:22:16 [error] 28203#0: *5 open() "/usr/share/nginx/www/emby/web/bower_components/requirejs/require.js" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/bower_components/requirejs/require.js?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"
2016/10/15 11:22:16 [error] 28203#0: *6 open() "/usr/share/nginx/www/emby/web/scripts/site.js" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/scripts/site.js?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"
2016/10/15 11:23:39 [error] 28305#0: *1 open() "/usr/share/nginx/www/emby/web/css/all.css" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/css/all.css?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"
2016/10/15 11:23:39 [error] 28305#0: *1 open() "/usr/share/nginx/www/emby/web/bower_components/requirejs/require.js" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/bower_components/requirejs/require.js?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"
2016/10/15 11:23:39 [error] 28306#0: *3 open() "/usr/share/nginx/www/emby/web/scripts/site.js" failed (2: No such file or directory), client: 178.39.112.114, server: localhost, request: "GET /emby/web/scripts/site.js?v=3.0.8000.0 HTTP/1.1", host: "example.ddns.net", referrer: "https://example.ddns.net/emby/web/index.html"

I've noticed that while index.html worked fine, it never was able to get .css and .js from there.

The nginx server I use is a multi-purpose one. I use it with ownCloud and to optimize the performance I've added this into the server config file:

	location ~* \.(?:css|js)$ {
		add_header Cache-Control "public, max-age=7200";
		add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
		add_header X-Content-Type-Options nosniff;
		add_header X-Frame-Options "SAMEORIGIN";
		add_header X-XSS-Protection "1; mode=block";
		add_header X-Robots-Tag none;
		access_log off;
	}

I've got stumped looking at that as the error logs clearly have issues with css and js files. This setting caches and adds headers to these type of files. Uncommenting this makes proxy pass work and emby Web loads correctly!

 

Thank you guys for helping and thank you pir8radio for making me take a second look at the correct location

  • Like 1
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...