Finally Understand Nginx

June 23, 2020

I finally was able to figure out nginx (at least for my use cases). My journey started off with trying to make a reverse proxy for jellyfin. Before, I just exposed a port to the internet and connected to it with server.com:port but that was ugly

Following the guide on their website I was able to get to use my domain name properly without needing to put in a port number and not expose more ports that needed but it still wasn’t what I wanted. The url was now server.com/jellyfin but I wanted server.jellyfin.com only because of aesthetics reason. I just liked how it looked. I tried a few times by looking at random guides on the internet but I could never figure it out.

Then on youtube, I watched a video by Luke Smith. In that video, he showed his viewers how to set up an email server on their own machine. The way he set up his server finally got me to understand how to set up nginx on my own server and how to set up my domain name. It still uses pretty much the same config provided by jellyfin but now I am able to use jellyfin.server.com.

It's a small change but it really made me happy. I will post the config here but leave out the stuff that certbot includes to set up https and redirecting to https. Don't forget to symlink to sites-enabled!

root@server:/etc/nginx/sites-available# cat jellyfin 
server {
        server_name jellyfin.server.com www.jellyfin.server.com;

        location / {
                proxy_pass http://localhost:8096;
                proxy_pass_request_headers on;

                proxy_set_header Host $host;

                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Host $http_host;

                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $http_connection;

                # Disable buffering when the nginx proxy gets very resource heavy upon streaming
                proxy_buffering off;
        }
}
home servernginxlinux

First Post