Closed rickk88 closed 2 years ago
Hi @rickk88, just wanted to let you now that i missed some Github notifications including this one. I tried this a while back but ran into different problems. I can look into it again if you want me too, what's your goal?
Hi Sander, I want to put the unencrypted port 7777 behind a reverse proxy that uses SSL, as non-HTTPS connections might be flagged in the future by the browsers and to not pass passwords over the network in plain text :)
But that already works right? So you have internet <-ssl-> reverseproxy <-non-ssl-> dsmrreader-ip:7777? Or do you refer to Ingress support (https://developers.home-assistant.io/docs/add-ons/presentation#ingress)
No, I want to publish https://proxy.domain.ext/dsmr -> dsmrreader-ip:7777 But because of the /dsmr I get error "Not Found. The requested resource was not found on this server"
Don't know how to properly configure this, it should be the right combination of: https://github.com/sanderdw/hassio-addons/blob/ingress_test/dsmr_reader/nginx/dsmr-webinterface https://github.com/sanderdw/hassio-addons/blob/ingress_test/dsmr_reader/rootfs/etc/services.d/nginx/run#L39-L43
I think we need to find someone who can help.
Not very knowledgeable in all of this, but I think you're almost there :)
In https://github.com/sanderdw/hassio-addons/blob/master/dsmr_reader/run.sh
Would it be possible to show the options for these settings in the package: DJANGO_STATIC_URL DJANGO_FORCE_SCRIPT_NAME DJANGO_USE_X_FORWARDED_HOST
Each of these should only be set as an environmental variable when the value isn't empty, or otherwise have a default: DJANGO_STATIC_URL="None" DJANGO_FORCE_SCRIPT_NAME="None" DJANGO_USE_X_FORWARDED_HOST="False"
For my environment it would be: DJANGO_STATIC_URL="/dsmr/" DJANGO_FORCE_SCRIPT_NAME="/dsmrreader" DJANGO_USE_X_FORWARDED_HOST="True"
At least that's what I think..
Hi @rickk88 , can you try the new Ingress support? See https://github.com/sanderdw/hassio-addons/issues/42#issuecomment-1121577693
Hi Sander, Ingress works like a charm! Will you still work on allowing manual configuration of some environmental variables for those not using Ingress? (That way we can choose to use Ingress or something like Nginx Proxy Manager as a reverse proxy)
Should not be that hard, in order for that to work you only want to be able to configure DJANGO_STATIC_URL and DJANGO_FORCE_SCRIPT_NAME right?
I think so yeah.
I have a test version ready in the develop branch, can you test it?
Hi Sander, I haven't figured out a working configuration with my proxy manager, maybe it's missing "DJANGO_USE_X_FORWARDED_HOST" ?
What proxy manager are you using and how do you want to set it up?
DJANGO_USE_X_FORWARDED_HOST is always set to True
Trying to use Nginx Proxy Manager (HA Addon) forwarding https://ha.domain.ext/dsmr to http://ha-ip:7777
It should work, i created a test setup myself:
So i think the only thing you need to do is configure the proxy.domain.ext entry that you already have in nginx proxy manager. In the Advanced tab put something like:
location /dsmr{
rewrite /dsmr(.*) $1 break;
proxy_pass http://192.168.100.60:7777/;
}
After this configure the addon with this script name (so the entire url):
https://proxy.domain.ext/dsmr/
Hi Sander, that helped me in the right direction. I configured: DJANGO_FORCE_SCRIPT_NAME as /dsmr DJANGO_STATIC_URL as /dsmr/static/
And the proxy like you provided. Had to restart my proxy manager before it started working, which I might have not done enough or was impatient. You're the man!
Would it be possible to support the environmental variables for reverse proxy support?
https://dsmr-reader.readthedocs.io/en/v4/reference/env-settings.html#django-use-x-forwarded-host https://dsmr-reader.readthedocs.io/en/v4/reference/env-settings.html#django-static-url
https://github.com/dsmrreader/dsmr-reader/issues/1080