Add a services and choose Cloudflare from the list.
Add the following details into the boxes.
email = your Cloudflare username (usually the email address)
API Token = On the Overview page on Cloudflare use the Global API token
Hostname = Your A record name from Cloudflare for example ddns.mymedia.cf
Domain = your top level domain mymedia.cf
We now need to setup a way for our router to update DNS-O-Matic.
I use a Unifi USG as my router and it requires the following details
Service = dyndns
Hostname = ddns.mymedia.cf
username = DNS-O-Matic email address
password = DNS-O-Matic password
server = updates.dnsomatic.com
DNS-O-Matci also offer a small program which can run on your LAN and update the details automatically.
So far I have documented different approaches to access Emby securely remotely.
This guide uses Cloudflare for DNS records of your domain name, create and maintain your SSL cert and add security to your connection.
So for anyone who doesnt know, Cloudflare acts like a middle man, or more like a big bouncer. Imagine you own a bar and you want security. You hire a bouncer and he lets your customers in but keeps the riff raff out. This is what cloudflare does it adds security to your Server, while allowing authorised people to access your server.
This guide will assume you have Emby Server already setup and working on your LAN.
Getting a Domain Name.
For this to work we need a domain name. You can get a free one from FreeNom or buy your own .com or .co.uk from a registrar such as NameCheap.
For this example I will use Freenom.
Search for the domain name you want. I will use mymedia.cf
Click Checkout. Enter your details. You will then see a button to manage domain, click that. Next click on Management Tools and Nameservers. You will see the below screen. Leave this open for now, we will come back to it.
Head over to Cloudflare Create an account with Cloudflare and then add your Domain name you entered above mymedia.cf. note. when adding your site and starting the scan it might fail due to DNS propagation. Give it 5-15 mins and try again.
Once your Domain Name appears in Cloudflare you can click 'Continue Setup' and you will see the page below.
Create an 'A Record'
Name = emby
Value = your WAN IP
Status = make sure its an Orange cloud
Select Free Plan
You will now be given Nameservers. Copy the 2 name servers from Cloudflare and enter them into FreeNom. If FreeNom has 4 delete all of them and only enter the 2 from cloudflare. Should look something like the below image.
It will take some time for DNS propagation before the Nameservers change to Cloudflare. In this time lets setup Emby Server and Port Forwarding on your router.
Go to your Emby Server and Dashboard Manager > Advanced.
Change your Public HTTP port to 80 and HTTPS port to 443. Enter your new domain name. I get emby.mymedia.cf from the CloudFlare DNS page. Emby was the name of the DNS record, so the full record is emby.mymedia.cf.
Save and Restart Emby.
Log into your router. All routers are different. Find the section to port forward and create a new rule.
Forward External port 443 to internal port 8920 and IP address of your Emby Server. You can also forward 80 to 8096, however this will mean users can connect insecurely to your Emby server.
Head back to CloudFlare and click 'Recheck Nameservers' if successfull you will see a green bar, and Cloudflare Active.
We now need to create a SSL cert for Cloudflare to connect to your Server Securely. On Cloudflare go to 'Crypto', and then 'Origin Certificates'.
Click Create Certificate, on the next screen leave everything default and click next.
You will now be given 2 boxes, A Certificate code and Private Key code.
Copy both of them into separate notepads and Save both. Call them cert.pem and private.key respectively
Click convert and you should end up with a PFX certificate.
Head back to Emby Server > Dashboard > Advanced.
Custom SSL certificate Path = your PFX file
Certificate Password = the one used above "what ever you want"
Save and Restart Emby
Head back to Cloudflare > Crypto Tab
You now need to change SSL from Flexible to Full.
(This means users connect to Cloudflare [uses cloudflare cert] Then Cloudflare connects to your emby server using the Cert we just created). Thus A Full SSL Path from user to server.
go to https://emby.mymedia.cf and enjoy your movies.
On Cloudflare > Crypto
You can enable 'Always use HTTPS' and 'Automatic HTTPS Rewrites'. Anyone trying to browse to HTTP will be forwarded to HTTPS.
On Cloudflare > Page Rules
Add the following rules to cache your images.
If you have a DHCP WAN IP then you will also need to do some additional steps so that Cloudflare forwards to your IP even if it changes. For this you need to use DNS-O-Matic, a Guide can be found HERE.
The instructions below are now obsolete. There is now a Option within Emby Server > Advanced to automatically configure Emby to advterise itself at HTTPS when going through a Reverse Proxy.
Secure Connection mode needs to be set to 'Handled By Reverse Proxy'
OLD Method Below
If you run Emby behind NGINX, then you would normally Connect to NGINX with HTTPS then NGINX will forward the request over your LAN using HTTP. This prevents double de-crypt/encrypt which uses more CPU cycles.
However if you use Emby Connect or Alexa for Emby then you will probably have noticed that on the Emby Server Dashboard is displays your external connection as HTTP and using port 80, which means Alexa wont work as it requires HTTPS on port 443.
So rather than create a double de-crypt/encrypt scenario we can edit the Emby system.xml file which fakes emby into advertising its external connections on HTTPS and port 443.
First we do need to create a real .pfx cert with a password.
There are 2 ways to create a SSL cert:-
This guide assumes you have either setup a DDNS or have an A record setup to point your Domain Name to your WAN IP. If you dont have this setup go here.
Step 1 - Port Forwarding
Every router is different and rather than try to describe how to do this on all the different brands I will simplify it so it is more relevant to all routers.
Log into your router
Head over to port forwarding
Create a new rule to forward port 443 and port 80 to the machine that NGINX will
be running on.
Step 2 - Installing NGINX
Head over to NGINX-Win and download the latest version of NGINX for Windows. As of writing this guide the latest version is 22.214.171.124 Violet.
Extract the .zip folder somewhere easy to find. for my example I will extract it to C:\NGINX\
Open up the config folder C:\NGINX\config
Open up notepad (I recommend Notepad++) and copy the following into it.
This is the location of our cert.pem and private.key. I have them located in my NGINX folder in the following location C:\NGINX\config\SSL To find out how to create the Certs please use the guide Easy Let's Encrypt Certificates At the bottom it describes how to create .pem certs.
The location block tells NGINX what to do when it received data and where to forward it to. It is also required for web sockets to work.
Edit the proxy_pass and point it to the location of your Emby Server. If it is running on the same machine as NGINX you can leave it as http://127.0.0.1:8096. If its running on another machine you will need to know the IP. http://192.168.1.10:8096 etc.
Save the notepad as nginx.config in the following location
Step 3 - Set NGINX as a Windows Service
To get NGINX to start with Windows we need to donwload an application called NSSM (Non-sucking service manager).
Download it and extract it. You will have a choice to use win32 or win64 version. Choice the version that relates to your Windows installation.
Copy the nssm.exe to C:\Windows\System32
Open up a command prompt (Run as administrator)
type the following
nssm install NGINX
It will now display this
Fill in the Path to the NGINX.exe and the Startup Directory as above.
Open up Service.msc and find the NGINX Service we just installed.
Right click and Start.
To Test, we can navigate to emby.mysite.com and it should bring up your Emby Server!
If you have any problems drop a comment below. I will also be creating a Troubleshooting NGINX post soon.