Use cloudflare on HA core without addon

I want to access my home assistant using cloudflare. I use core installation on an orange pi with armbian so I cannot use addons.

Until recently I was using port forwarding with a custom domain but my new router has a lot of restrictions with port forwarding so I decided to create a tunnel on cloudflare. My domain is already on cloudflare and working but I have no experience with tunnels.

I read here that there are two methods to create a tunnel. I tried both, the tunnel is created and I see status: healthy but I cannot access home assistant. I get error 400 on browser.

I have added these in configuration.yaml:

homeassistant:
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 192.168.0.0/16
        - 103.21.244.0/22
        - 103.22.200.0/22
        - 103.31.4.0/22
        - 104.16.0.0/12
        - 108.162.192.0/18
        - 131.0.72.0/22
        - 141.101.64.0/18
        - 162.158.0.0/15
        - 172.64.0.0/13
        - 173.245.48.0/20
        - 188.114.96.0/20
        - 190.93.240.0/20
        - 197.234.240.0/22
        - 198.41.128.0/17
      allow_bypass_login: true

http:
  use_x_forwarded_for: true
  trusted_proxies:
  - MY_SERVER_IP

I also removed the references for the previous certificates from Let’s Encrypt.
Are these settings correct? Should I add anything else?
Should I transfer any certificates from cloudflare to my server?
Could anyone share their tunnel settings from cloudflare dashboard to compare with mine?

The configuration above was obviously wrong. I messed it up after searching on various websites.
This is what worked:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 192.168.0.0/16
    - 103.21.244.0/22
    - 103.22.200.0/22
    - 103.31.4.0/22
    - 104.16.0.0/12
    - 108.162.192.0/18
    - 131.0.72.0/22
    - 141.101.64.0/18
    - 162.158.0.0/15
    - 172.64.0.0/13
    - 173.245.48.0/20
    - 188.114.96.0/20
    - 190.93.240.0/20
    - 197.234.240.0/22
    - 198.41.128.0/17

Also in cloudflare tunnel settings I had added:
service: http
URL: localhost:8123
It worked after replacing localhost with my server’s internal IP. (192.168.x.x)

2 Likes

Where do I have to put the configuration? In the home assistant docker-compose.yaml? Thank you

that would be configuration.yaml (within Home Assistant)

1 Like