70p4z / ha-reverse-proxy-path Goto Github PK
View Code? Open in Web Editor NEWHome assistant reverse proxy script to allow for sub path chrooting (http://acme.com/ha/). Which was not possible with bare home assistant
Home assistant reverse proxy script to allow for sub path chrooting (http://acme.com/ha/). Which was not possible with bare home assistant
My webserver is running apache and I have several paths working quite nicely (Jenkins, roundcube, gitea, gitweb). However with your script, I get this error:
----------------------------------------
Exception occurred during processing of request from ('192.168.2.2', 34674)
Traceback (most recent call last):
File "/usr/lib/python3.10/socketserver.py", line 683, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python3.10/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.10/socketserver.py", line 747, in __init__
self.handle()
File "/usr/lib/python3.10/http/server.py", line 432, in handle
self.handle_one_request()
File "/usr/lib/python3.10/http/server.py", line 420, in handle_one_request
method()
File "/home/amunro/home-assistant/./hacs-subpath-reverseproxy.py", line 188, in do_GET
resp.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:8123/api/websocket
My apache is using simply the following; maybe I need a ProxyPassReverse line as well?:
ProxyPass /ha http://192.168.2.253:8124
My apache and ha are running on different hosts; with ha running as a docker container. I can access locally using the ip address.
I get the login page, am able to login, and then just get a big home-assist icon in the middle of the web page and a url of https://my-domain/ha/?auth_callback=1&code=681... .
Thanks in advance.
After multiple hours of attempt:
location /ha/ {
set $prefix '/ha';
proxy_pass http://127.0.0.1:8123/;
proxy_redirect ~^/(.*) $scheme://$host$prefix/$1;
proxy_set_header Accept-Encoding "";
# These configuration options are required for WebSockets to work.
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-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
sub_filter_types text/html text/css application/javascript text/javascript;
sub_filter_once off;
sub_filter '/frontend_' '$prefix/frontend_';
sub_filter '/static/' '$prefix/static/';
sub_filter '/local/' '$prefix/local';
sub_filter '/auth/' '$prefix/auth/';
sub_filter '/api/' '$prefix/api/';
sub_filter '/service_worker.js' '$prefix/service_worker.js';
sub_filter '/manifest.json' '$prefix/manifest.json';
subs_filter_types text/html text/css application/javascript text/javascript;
subs_filter '[a-zA-Z0-9_\.]*history\.pushState' 'hpS' 'gr';
subs_filter '[a-zA-Z0-9_\.]*history\.replaceState' 'hrS' 'gr';
subs_filter '([a-zA-Z0-9_\.]*location.pathname)' 'lpn($1)' 'gr';
subs_filter '\.\.\.history\.state([^a-zA-Z0-9_])' '...window.history_state$1' 'gr';
subs_filter '[a-zA-Z0-9_\.]*history\.state([^a-zA-Z0-9_])' 'window.history_state$1' 'gr';
sub_filter '</body>' '<script> function hpS(d,o,url){console.log("push "+url);window.history_state=url;window.history.pushState(d,o,"$prefix"+url)}; function hrS(d,o,url){console.log("replace "+url);window.history_state=url;window.history.replaceState(d,o,"$prefix"+url)} function lpn(e){ const prefix = "$prefix"; const hasPrefix = e.indexOf(prefix) === 0; return hasPrefix ? e.substr(prefix.length):e;}</script></body>';
}
Hi, could you tell me if it is possible to run in daemon or background mode, I would be interested in being able to automate its execution (to be able to activate or deactivate it with monitoring programs like "Monit")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.