I’m trying to expose Hass.io to Alexa in order to control my device with an echo dot.
In order to do that, I do have 2 raspberry pies connected to my network:
- 1 Hass.io instance (listening to 192.168.x.x:8123 - default configuration)
- 1 nginx instance which is also running duckdns scripts and certbot (listening to 192.168.x.y on ports 80 and 443)
Ports 80 and 443 are forwarded on my router to the nginx server.
so far so good…
I trying to configure nginx to act as a reverse proxy for Home Assistant (but on a different url). The idea is to have home assistant answer to calls to https://zzzz.duckdns.org/hass (using / hass because I don’t want to consume the whole url space with Home Assistant only).
My nginx configuration looks like this:
# Default server configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
#root /var/www/html;
#index index.html index.htm index.nginx-debian.html;
server_name zzz.duckdns.org;
#location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
#}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/zzzz.duckdns.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/zzzz.duckdns.org/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
if ($scheme != "https"){
return 301 https://$host$request_uri;
} # managed by Certbot
location /hass {
proxy_buffering off;
proxy_pass http://192.168.x.y:8123/;
proxy_set_header Host $host;
proxy_redirect http:// https://;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection $connection_upgrade;
}
}
When I connect to https://zzzz.duckdns.org, the page is loading fine, but all js scripts are failing to load (http 404 errors), which make sense because the calls are made to https://zzzz.duckdns.org/frontend_es5/core-6a354e5eb94e5c8a2f58a0a18f948058.js (for instance).
I believe I should add some configuration to my hass.io configuration to generate the correct html (calling for /hass/… instead of /…)
Any help will be greatly appreciated!