Jump to content

Ubuntu + Docker + NGINX reverse proxy + Emby


mengoshmink

Recommended Posts

mengoshmink

Hi guys,

I'm afraid this has probably been asked before as I have tried to follow several of the posts on this forum. Namely:

and

I haven't setup a ssl cert yet but I am assuming this is not critical if I am testing things on port 80.

My default.conf from /etc/nginx/conf.d/ is below.

If I add anything above "server {" it stops working. I suspect it's something trivial like a missing } but I am at a loss to what.

# Forward everything into Emby
server {
    listen [::]:80;
    listen 80;
    server_name video.dyndns.org;

proxy_hide_header X-Powered-By;
add_header X-Xss-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff"  always;
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header 'Referrer-Policy' 'no-referrer';

add_header Content-Security-Policy "frame-ancestors dyndns.org video.dyndns.org;";
#add your domainname and all subdomains listed on your cert

     location / {
        proxy_pass http://192.168.1.83:8096;
# Local emby ip and non SSL port

proxy_hide_header X-Powered-By;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#Next three lines allow websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
    }
}

Any suggestions, as always, welcome 🙂

Link to comment
Share on other sites

mengoshmink

Sorry for the lack of useful information.

I didn't realise but it actually crashes the docker container; which is why I can no longer connect. As an example:

Adding to the default.conf

worker_processes  auto;

error_log  logs/error.log;

events {
    worker_connections  8192;
}

# Forward everything into Emby

Results in:

Quote

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/04/17 23:14:06 [emerg] 1#1: "worker_processes" directive is not allowed here in /etc/nginx/conf.d/default.conf:1
nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/conf.d/default.conf:1

 

Link to comment
Share on other sites

OK so if you think the server is crashing then please attach the emby server log from that time:

Thanks.

Link to comment
Share on other sites

mengoshmink

Hi Luke,

sorry! I've been a bit rubbish at explaining.

It's not the Emby server which is crashing but the nginx (reverse proxy) docker container. Or more accurately it's the nginx docker container not (re)starting. The last few lines of the container log are in my previous post. I am starting to understand why; I have put conf files in the wrong place with the wrong file names. I think I've unfairly come to here for help as it's such a good community. I'll persist and try and report back if / when I fix.

Link to comment
Share on other sites

Ah ok, got it. That is strange. Never heard of that before. Please let us now what you find. Thanks.

Link to comment
Share on other sites

  • 2 weeks later...
CassTG

Hi I would seriously take a look at linuxserver swag docker for your ssl reverse proxy setup. It's one of the easiest to set up comes with tonnes of pre configured proxy scripts has fail2ban built in and also can run nginx websites. It's the easiest to setup and near faultless. Also handles your security certs either letsencrypt or zerossl and can handle also via dns challenges for cert renewal

  • Like 1
Link to comment
Share on other sites

mengoshmink

Hi CassTG,

Thank you for your suggestion to use a linuxserver.io image and container. I have used a couple in the past but in this instance I have not because I wanted to learn how to do it myself and understand a little more of how it works.

I plan to report back with a full explanation of how I got it working but for now I'm over the problem above. I'm continuing in this thread as it maybe related to my setup / configuration.

The current problem is my audio files are semi-intermittent (did work, doesn't anymore) at starting playback. I have a podcasts folder which I access from a subfolder of a NFS share. This is added to my Emby library as an audiobook library. When I access Emby from a web browser and playback an audio file it works as expected. When I try via my Amazon Fire Stick 4K it errors, "Error playing audio". The really odd thing is that it did work initially. Current version of Emby server 4.6.7.0 and current version of Emby Fire Stick app 2.0.70a

Emby server log attached

embyserver.txt

Link to comment
Share on other sites

2 hours ago, mengoshmink said:

Hi CassTG,

Thank you for your suggestion to use a linuxserver.io image and container. I have used a couple in the past but in this instance I have not because I wanted to learn how to do it myself and understand a little more of how it works.

I plan to report back with a full explanation of how I got it working but for now I'm over the problem above. I'm continuing in this thread as it maybe related to my setup / configuration.

The current problem is my audio files are semi-intermittent (did work, doesn't anymore) at starting playback. I have a podcasts folder which I access from a subfolder of a NFS share. This is added to my Emby library as an audiobook library. When I access Emby from a web browser and playback an audio file it works as expected. When I try via my Amazon Fire Stick 4K it errors, "Error playing audio". The really odd thing is that it did work initially. Current version of Emby server 4.6.7.0 and current version of Emby Fire Stick app 2.0.70a

Emby server log attached

embyserver.txt 14.03 kB · 0 downloads

Hi, can you try our official docker for comparison purposes? Thanks.

Link to comment
Share on other sites

mengoshmink

Hi Luke,

I am, and always have, used your official docker container "image: emby/embyserver:latest".

Link to comment
Share on other sites

On 4/17/2022 at 3:32 PM, mengoshmink said:

Hi guys,

I'm afraid this has probably been asked before as I have tried to follow several of the posts on this forum. Namely:

and

I haven't setup a ssl cert yet but I am assuming this is not critical if I am testing things on port 80.

My default.conf from /etc/nginx/conf.d/ is below.

If I add anything above "server {" it stops working. I suspect it's something trivial like a missing } but I am at a loss to what.

# Forward everything into Emby
server {
    listen [::]:80;
    listen 80;
    server_name video.dyndns.org;

proxy_hide_header X-Powered-By;
add_header X-Xss-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff"  always;
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header 'Referrer-Policy' 'no-referrer';

add_header Content-Security-Policy "frame-ancestors dyndns.org video.dyndns.org;";
#add your domainname and all subdomains listed on your cert

     location / {
        proxy_pass http://192.168.1.83:8096;
# Local emby ip and non SSL port

proxy_hide_header X-Powered-By;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#Next three lines allow websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
    }
}

Any suggestions, as always, welcome 🙂

When you say "add anything", what's an example? What does "stops working" mean?

Link to comment
Share on other sites

mengoshmink

Sorry, I think I have made things necessarily confusing. The original post is fixed.

This is the problem ie what has stopped working:

Quote

The current problem is my audio files are semi-intermittent (did work, doesn't anymore) at starting playback. I have a podcasts folder which I access from a subfolder of a NFS share. This is added to my Emby library as an audiobook library. When I access Emby from a web browser and playback an audio file it works as expected. When I try via my Amazon Fire Stick 4K it errors, "Error playing audio". The really odd thing is that it did work initially. Current version of Emby server 4.6.7.0 and current version of Emby Fire Stick app 2.0.70a

 

Link to comment
Share on other sites

1 hour ago, mengoshmink said:

Bad news I'm afraid ...

On my Amazon Fire Stick 4K browsed to https://emby.media/emby-for-android.html

Downloaded  the x86 APK

Allowed installs from unknown sources.

Opened the APK, error, "This app isn't compatible with your TV"

Sorry!

Hi, try the armv7 version.

Link to comment
Share on other sites

mengoshmink

Just checking you want me to try the Android APK and not the https://emby.media/emby-for-fire-tv.html ?

Uninstalled the App Store version

Installed the Android arm 7 APK.

Connected to the server manually, as usual.

Signed in without pin, as usual.

Browsed to a audio file.

No playback but not no error.

Tried to download the same audio file, the download icon turned blue but I don't know where the audio file is.

Tried a different audio file, error says "no compatible streams", which usually means for me that the server can not access the media location.

Tried from my laptop, playback okay.

Back to FireStick with Android arm7 APK

Tried to playback the downloaded audio file, nothing, then it started to playback.

Tried a different file, just playback, no download. It plays.

Tried a few things, all okay. I think the sequence above is correct.

Uninstalled the Android app.

Reinstalled the Amazon App Store version.

Tried the same files.

No playback.

::offtopic:: Woke up this morning realising how careless I'd been not trying the arm apk. Tried to get here before anyone noticed.

embyserver android arm7 debug.txt

Edited by mengoshmink
Link to comment
Share on other sites

10 hours ago, mengoshmink said:

Just checking you want me to try the Android APK and not the https://emby.media/emby-for-fire-tv.html ?

Uninstalled the App Store version

Installed the Android arm 7 APK.

Connected to the server manually, as usual.

Signed in without pin, as usual.

Browsed to a audio file.

No playback but not no error.

Tried to download the same audio file, the download icon turned blue but I don't know where the audio file is.

Tried a different audio file, error says "no compatible streams", which usually means for me that the server can not access the media location.

Tried from my laptop, playback okay.

Back to FireStick with Android arm7 APK

Tried to playback the downloaded audio file, nothing, then it started to playback.

Tried a different file, just playback, no download. It plays.

Tried a few things, all okay. I think the sequence above is correct.

Uninstalled the Android app.

Reinstalled the Amazon App Store version.

Tried the same files.

No playback.

::offtopic:: Woke up this morning realising how careless I'd been not trying the arm apk. Tried to get here before anyone noticed.

embyserver android arm7 debug.txt 81.89 kB · 0 downloads

No, this:https://emby.media/emby-for-android.html

Link to comment
Share on other sites

16 minutes ago, mengoshmink said:

Cool, that's the one I installed.

What version number did you install?

Link to comment
Share on other sites

mengoshmink

emby-android-google-armeabi-v7a-release

Assuming there hasn't been a new release in the last 14 hours.

Link to comment
Share on other sites

mengoshmink

Strangely it started working again last night. For reference I'll outline my setup steps and configuration below, but it will be later, I need to rest.

Thank you all, especially for your patience with helping  me.

Link to comment
Share on other sites

mengoshmink

So, my original problem was I couldn't get nginx to work as a reverse proxy to my Emby server. I have now solved this problem. Essentially it was caused by lack of knowledge of where the nginx config files needed to reside and what they needed to contain. nginx.conf in /etc/nginx/, default.conf in /etc/nginx/conf.d/ and video.dyndns.org.confdocker-compose.yml either to the tail of nginx.conf or /etc/nginx/sites-enabled.

Here is a brief overview to my configuration in the hope it may help someone else. It is far from a guide; frankly I don't remember all the steps I took and it would take more energy than I have right now to write it. Not to say I never will ...

  • Firewall on the server blocks all traffic to normal Emby service(s) eg 8096.
  • Add a firewall rule to permit traffic to SSL eg 443.
  • Create docker network. This is for Emby and the nginx containers to communicate with each other.
  • Amend docker-compose.yml for the Emby and the nginx containers to use this new network.
  • Create in /etc/nginx/conf.d/ a file, default.conf Initially I used a blank file, this worked fine.
  • Create in /etc/nginx/ a file mime.types. I got mine from the source tarball on the nginx website.
  • Configure Emby server. I only made changes to external domain (for my external dyndns) and secure connection mode: handled by reverse proxy.
  • Firestick connection updated to https://video.dyndns.org port 443
  • Router NAT configuration updated. Same as firewall, removed 8096, added 443.

Something I found invaluable was the container logs, especially nginx, to see the errors and fix them.

docker container logs nginx-reverse-proxy -f

nginx.conf video.dyndns.org.conf

  • Thanks 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...