Help needed with the NGINX addon for Hassio

Cool, so just to make sure we are on the same page, you got to the hassos command line by typing login at the hassio >?

I booted my old raspberry pi running hass.io. Once i type ‘login’ at the hassio > prompt (and login as root) I have the typical # prompt for root access. Now I can run the docker command.

Try docker ps will list your running containers.

FWIW

Ok, I am in. How do you edit it? nano is not working

Also not sure which coimmands are working, for example to see the directories? dir is also not working

IIRC, hassos is just another linux, maybe busybox?. If you ran the docker ‘exec’ command I suggested, you are running in the bash shell. A simple ‘ls’ should work for listing a directory? I used the ‘vi’ editor.

Hello,

Sorry to bump in here, but I couldn’t find a better thread for my issue:

Until recently, I have had a a port forwarding configured on my internet router 443->443 to my homeassistant instance (running on an Raspberry Pi 4 on hassio) configured with ssl certificates from let’s encrypt. Everything was working fine and I was happy…

Now I want to expose a second server on the same port and I have installed the nginx addon. I reused the ssl certificates that I (manually) got from let’s encrypt. I configured everything to the best of my knowledge. And here is the problem:
When I configure nginx without ssl encryption, I can access my homeassistant instance from the internet
When I configure nginx to use ssl encryption (with the ssl certificates), I get an error when I try to load my homeassistant instance from the internet.
The weird thing is: If I force the browser to use http on port 443, I will get plain text. Basically, nginx does not encrypt and if my internet browser tries to decrypt plain text, it will obviously fail.

Does anyone know, what is going on?

I can provide config / logs, whatever is helpful …

Thanks,

R

For anyone that finds this post trying to work with the official NGINX addon and doesn’t want to just use the “Nginx Proxy Manager addon” then to use the customize server features you need to create a folder in /usr/share/hassio/share/nginx_proxy inside that folder create a file with any name but ending in .conf e.g. other_server.conf

in that file you want similar to the following:

If you want another service on port 80

    server {
        server_name 192.168.1.2;
        listen 80;
        location / {
            proxy_pass http://192.168.1.2:41080;
            proxy_set_header Host $host;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

Or on port 443:

    server {
        server_name 192.168.1.2;
        ssl_certificate /share/nginx_proxy/public.crt;
        ssl_certificate_key /share/nginx_proxy/private.key;
        listen 443 ssl http2;

        location / {
            proxy_pass http://192.168.1.2:41080;
            proxy_set_header Host $host;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

So the way this works is the official nginx add on works based on the domain specified in the config settings and will only forward that domain on to the Home Assistant server. Then these extra server blocks will kick in based on the server_name matching so in the example above when requesting based on IP address it will hit these server blocks instead of the home assistant ones and will proxy to another server.

You could also do server_name: a.nother.domain.com then you can run two domains from the one nginx instance.

Note you may not need all the settings i’ve set above - you need to check the nginx docs / docs for the service you are proxying.

I’ve not done the defaults component so I can’t comment on that.

1 Like

thanks. I did come across this searching for the same use case and willing to spend time getting this right, vs. jumping to a new addon (Proxy manager - though from what I read it’s a better option?!)
will report if this works :slight_smile:

EDIT: crap, looks like I’m using the supervised hass.io install where all add-ons are running as separate containers :S

@foxy82 , you say:
"to use the customize server features you need to create a folder in /usr/share/hassio/share/nginx_proxy inside that folder create a file with any name but ending in .conf e.g. other_server.conf"

But the instructions say:
“…additional NGINX configuration files for the default server and additional servers are read from files in the /share directory specified by the default and servers variables.”

Which one is it?

On one of my installations (where the add-on works perfectly for the main site), I cannot get any other server configured through the Customize Section. On one other server I have, it works out of the ‘/share/’ folder.

Any help appreciated.

I documented what I needed to do but that was over a year ago now so things may have moved on.

I don’t use that add on anymore and created my own due to a ‘feature’ of it that didn’t work for me details here in case you are hitting the same problem: