2024年11月23日星期六 下午10:14:38

Home Assistant Remote access test step by step(cf +vps+nginx+frp +raspberry pi 3B+)

2 年 前
#3761 引用
Home Assistant Remote access test step by step


Quick start



Step 1:Home Assistant access with cloudflare
Step 2:Home Assistant access with  nginx proxy

Step 3:Home Assistant access with nginx proxy and Let’s Encrypt

Step 4:Home Assistant access with frp

Step 5:Configuring Home Assistant for Reverse Proxy


0
2 年 前
#3762 引用
step 1.cloudflare

frpsserver.matterxiaomi.com  dns only  -> vps on vultr



forward extenal port 8123 to your local IP port 8123  access via http

vps with  static public ip

ha webserver listen  on 0.0.0.0:8123 on vps


nginx webser 80 port for test


0
2 年 前
#3763 引用
1
0
2 年 前
#3764 引用
1
0
2 年 前
#3765 引用
Case 1:vps public static ipaddress + domain with http = directly  vist
0
2 年 前
#3766 引用
1
0
2 年 前
#3767 引用
1
0
2 年 前
#3768 引用
see log on home assistant

you can be found in the Home Assistant frontend by going to
 Configuration > Settings > logs 
show as follow:


goto :

http://192.168.2.50:38123/config/logs




result


2022-03-31 22:31:33 INFO (MainThread) [homeassistant.core] Timer:starting
2022-03-31 22:31:43 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
2022-03-31 22:31:43 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
2022-03-31 22:31:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
2022-03-31 22:31:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
^C^CTraceback (most recent call last):
  File "/usr/local/bin/hass", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/homeassistant/__main__.py", line 388, in main
    exit_code = asyncio_run(setup_and_run_hass(config_dir, args))
  File "/usr/local/lib/python3.6/dist-packages/homeassistant/util/async_.py", line 27, in asyncio_run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 471, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.6/asyncio/base_events.py", line 438, in run_forever
    self._run_once()
  File "/usr/lib/python3.6/asyncio/base_events.py", line 1415, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/lib/python3.6/selectors.py", line 445, in select
    fd_event_list = self._epoll.poll(timeout, max_ev)


0
2 年 前
#3822 引用
Unable to connect to Home Assistant. retry - Access to HA via browser is failure








chrome ,press F12


chrome ,press F12

core.c46795dd.js:1 WebSocket connection to 'wss://http://ha.usdotnet.com/api/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400




you can be found in the Home Assistant frontend by going to Configuration > Settings > logs  show as follow:


Logger: homeassistant.components.http.ban
Source: components/http/ban.py:125
Integration: HTTP (documentation, issues)
First occurred: 8:25:51 AM (2 occurrences)
Last logged: 12:41:23 PM

Login attempt or request with invalid authentication from 58.47.44.89 (58.47.44.89). (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36)



The http integration serves all files and data required for the Home Assistant frontend. You only need to add this to your configuration file if you want to change any of the default settings.

use_x_forwarded_for boolean (optional, default: false)
Enable parsing of the X-Forwarded-For header, passing on the client’s correct IP address in proxied setups. You must also whitelist trusted proxies using the trusted_proxies setting for this to work. Non-whitelisted requests with this header will be considered IP spoofing attacks, and the header will, therefore, be ignored.

# https://www.home-assistant.io/integrations/http/
http:
  server_port: 38123
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1      # Add the IP address of the proxy server
    - 127.0.0.0/24  # You may also provide the subnet mask
    - 192.168.2.1      # Add the IP address of the proxy server
    - 192.168.2.50      # Add the IP address of the proxy server
    - 192.168.2.0/24  # You may also provide the subnet mask
    - 114.55.28.108  # You may also provide the subnet mask
  ip_ban_enabled: False
  login_attempts_threshold: 5


https://www.home-assistant.io/integrations/http
0
2 年 前
#3842 引用
Unable to connect to Home Assistant. retry  - check ssl


Reason


Your connection is not private
Attackers might be trying to steal your information from ha.usdotnet.com (for example, passwords, messages, or credit cards)


Sloved

Found the following certs:
  Certificate Name: domain.com
    Serial Number: 3311da39329396f7a510fc3fcd18e59ce30
    Key Type: RSA
    Domains: ha.domain.com
    Expiry Date: 2022-09-19 12:52:35+00:00 (INVALID: EXPIRED)
    Certificate Path: /etc/letsencrypt/live/usdotnet.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/usdotnet.com/privkey.pem



Manually certbot  renew Certificate



sudo certbot certificates
service nginx stop
certbot renew
sudo certbot certificates
service nginx restart
0