Giter Club home page Giter Club logo

ha-reverse-proxy-path's People

Contributors

70p4z avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ha-reverse-proxy-path's Issues

Apache config?

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.

nginx standalone solution

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>';
        }

Daemon Mode

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")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.