Nginx / Unraid / Home Assistant

I’m having a hell of time getting Hass running behind Nginx. All my other services run fine but Hass has had me stumped for a couple of weeks now.

I’m hoping someone can have a look at my Nginx conf and see if they can spot the problems(s)

Blockquote
###################################################
#////////////////////////////////////////////////SERVER BLOCK\\\\\\\\\\\#
###################################################
#REDIRECT TRAFFIC FROM www.domain.com TO https://domain.com#
server {
listen 80;
listen 443 ssl http2;
server_name www.mydomain.duckdns.org; #CHANGE THIS TO YOUR DOMAIN NAME!
return 301 https://mydomain.duckdns.org$request_uri; #CHANGE THIS TO YOUR DOMAIN NAME!
}
#REDIRECT HTTP TRAFFIC TO https://[domain.com]#
server {
listen 80;
server_name mydomain.duckdns.org; #CHANGE THIS TO YOUR DOMAIN NAME!
return 301 https://$server_name$request_uri;
}
#######################################################
#////////////////////////////////////////////////MAIN SERVER BLOCK\\\\\\\\\\#
#######################################################
#MAIN SERVER BLOCK#
server {
listen 443 ssl http2 default_server;
server_name mydomain.duckdns.org; #CHANGE THIS TO YOUR DOMAIN NAME!
#Certificates from LE container placement#
ssl_certificate /config/keys/letsencrypt/fullchain.pem;
ssl_certificate_key /config/keys/letsencrypt/privkey.pem;
#Strong Security recommended settings per cipherli.st#
ssl_dhparam /config/nginx/dhparams.pem; # Bit value: 4096
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
ssl_session_timeout 10m;
#Settings to add strong security profile (A+ on securityheaders.io/ssllabs.com)#
add_header Strict-Transport-Security “max-age=63072000; includeSubDomains; preload”;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection “1; mode=block”;
add_header X-Robots-Tag index; #SET THIS TO none IF YOU DONT WANT GOOGLE TO INDEX YOU SITE!
add_header Content-Security-Policy “frame-ancestors https://*.$server_name https://$server_name”; ## Use *.domain.com, not .sub.domain.com
add_header X-Frame-Options “ALLOW-FROM https://.$server_name” always; ## Use .domain.com, not .sub.domain.com when using this on a sub-domain that you want to iframe!
add_header Referrer-Policy “strict-origin-when-cross-origin”;
proxy_cookie_path / “/; HTTPOnly; Secure”;
more_set_headers “Server: Classified”;
more_clear_headers ‘X-Powered-By’;
#Custom error pages#
error_page 400 401 402 403 404 405 408 500 502 503 504 $scheme://$server_name/error.php?error=$status;
error_log /config/log/nginx/error.log;
#AUTHORIZATION BLOCK#
location ~ /auth-(.
) {
internal;
proxy_pass http://192.168.1.134:8282/api/?v1/auth&group=$1;
proxy_set_header Content-Length “”;
}
#BLOCK ORGANIZR DASHBOARD FILES#
location ~ /loginLog.json|chat.db|users.db|org.log|org.db|organizrLog.json|organizrLoginLog.json {
return 404;
}
#ORGANIZR CONTAINER
location / {
proxy_pass http://192.168.1.134:2020;
include /config/nginx/proxy.conf;
proxy_intercept_errors on; #For custom Organizr error page
}
#####################################################
#////////////////////////////////////////////////SUBDIRECTORIES\\\\\\\\\\\#
#####################################################
#SONARR CONTAINER
location /sonarr {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.1.134:8989/sonarr;
}
#Radarr CONTAINER
location /radarr {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.1.134:7878/radarr;
}
#Sabnzbd CONTAINER
location /sabnzbd {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.1.134:8080/sabnzbd;
}
#OMBI CONTAINER
location /ombi {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.1.134:3579/ombi;
}
#Monitorr Container
location /monitorr {
proxy_pass http://192.168.1.134:3131/monitorr;
add_header X-Frame-Options SAMEORIGIN;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#tautulli CONTAINER
location /tautulli/ {
proxy_pass http://192.168.1.134:8181;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 90;
proxy_set_header X-Forwarded-Proto $scheme;
set $xforwardedssl “off”;
if ($scheme = https) {
set $xforwardedssl “on”;
}
proxy_set_header X-Forwarded-Ssl $xforwardedssl;
proxy_redirect ~^(http(?:s)?://)([^:/]+)(?::\d+)?(/.
)?$ $1$2:$server_port$3;
}
}
##################################################
#////////////////////////////////////////////////SUBDOMAINS\\\\\\\\\\\\#
#################################################
server {
listen 443 ssl;
server_name hass.mydomain.duckdns.org;
location / {
proxy_pass https://192.168.1.134:8123/;
proxy_http_version 1.1;
proxy_set_header Connection “”;
}
location /api/websocket {
proxy_pass https://192.168.1.134:8123/api/websocket;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
}
}

Hass Config:

http:
Secrets are defined in the file secrets.yaml
api_password: test
#Uncomment this if you are using SSL/TLS, running in Docker container, etc.
#base_url: hass.mydomain.duckdns.org
Tried:
base_url: /hass
base_url: /hass/
base_url: hass.mydomain.duckdns.org
Commented out

Blockquote

check https://www.home-assistant.io/docs/ecosystem/nginx/
you’re missing the part around connection_upgrade

Also you didn’t tell what is your actual issue
You should also put your config under Blockquote so it’s readable

Sorry about that, refomatted, It’s quoted as it is in my conf file.

Here is the error I’m getting:

My other services work as mydomain.duckdns.org/radarr but from what I’ve read HASS doesn’t like to run as a subdirectory and should be run under a subdomain.

So I managed to get Home Assistant running as root with the following code borrowed from here:

But had to change this:

ssl_dhparam /config/nginx/dhparams.pem;

add_header Strict-Transport-Security “max-age=31536000; includeSubdomains”;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers <‘Ciphers’>
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

To This"

ssl_dhparam /config/nginx/dhparams.pem; # Bit value: 4096
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
ssl_session_timeout 10m;

upstream backend {
server 192.168.0.111:19999;
keepalive 64;
}

map $http_upgrade $connection_upgrade {
default upgrade;
’’ close;
}

server {

listen 443 ssl default_server;
root /config/www;
index index.html index.htm index.php;

server_name www.duckdns.org;

ssl_certificate /config/keys/letsencrypt/fullchain.pem;
ssl_certificate_key /config/keys/letsencrypt/privkey.pem;
ssl_dhparam /config/nginx/dhparams.pem;

add_header Strict-Transport-Security “max-age=31536000; includeSubdomains”;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers <‘Ciphers’>
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

proxy_buffering off;

client_max_body_size 0;

location / {
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-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

Fix the “It appears that your reverse proxy set up is broken" error.

proxy_pass http://192.168.0.111:8123;
proxy_read_timeout 90;

proxy_redirect http://192.168.0.111:8123 https://hass.duckdns.org;
}

location /sonarr {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.0.111:8989;
}

location /radarr {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.0.111:7878;
}

location /ombi {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.0.111:3579/ombi;
}
}

I don’t really want to run Hass at root but as a subdomain but at least this is a step in the right direction.

Got it sorted out, ended up being a error in LE for the Subdomain.

In case anyone cares to have a look at the nginx conf.

https://pastebin.com/cFzY45sV