Nginx separate reverse proxy

Hi there!
I’m fairly new to both NginX and Home assistant, I did follow quite a few tutorials but I’m looking over something essential and I can’t figure out what exactly. I can’t seem to get the reverse proxy working as it should. I’m just trying to access it on the IP from my Nginx server over http, so no SSL config (yet).

Proxy server: 10.0.0.53
Home assistant server 10.0.0.50:8123

configuration.yaml file:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 10.0.0.53 # Add the IP address of the proxy server
    - 127.0.0.1
  ip_ban_enabled: true # use this to enable auto IP ban
  login_attempts_threshold: 10 # set the number of allowed login attempts

Nginx config file:

server {
        gzip off;

        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        #index index.html index.htm index.nginx-debian.html;

        server_name youknowhat.dev;

        location / {
                proxy_pass http://10.0.0.50:8123;
                #proxy_http_version  1.1;
                #proxy_set_header Host $host;
                #proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
                #proxy_set_header    Upgrade          $http_upgrade;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;

                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.

When I try to access http://10.0.0.53 (proxy IP) I get some 404 errors…

Can someone point me into the right direction or tell me what I’m doing wrong?

Thanks in advance!

Get a cert and use https. Please don’t http this.

Your nginx config is wrong for HA. I can post something later since I can’t find good example now. There example in HA docs

1 Like

Home assistant uses websockets, which requires extra configuration in nginx.

See the nginx config here to use as a guide

1 Like

Soooooo, it seems like yesterday I was just looking at it for too long. I tried exactly what you said I’m sure of it…
The config is now:

        location / {
                proxy_pass http://10.0.0.50:8123;
                proxy_http_version  1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_set_header Host $host;
                #proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
        }

And for anyone with the same issue, do comment out the following line

try_files $uri $uri/ =404;

Anyway resolved, a clear mind does help a lot.