From 8a8b0053ca8611aa46c09c57f47505615c1c3c64 Mon Sep 17 00:00:00 2001 From: Brenner-Bot Date: Sat, 5 Feb 2022 15:18:07 +0000 Subject: [PATCH] :tada: Release of add-on Cloudflared 0.4.0 --- README.md | 6 +-- cloudflared/CHANGELOG.md | 12 +++-- cloudflared/DOCS.md | 101 ++++++++++++++++++++++++++------------- cloudflared/config.yaml | 5 +- 4 files changed, 82 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 5eac26e..aac0e89 100644 --- a/README.md +++ b/README.md @@ -86,10 +86,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -[addon-cloudflared]: https://github.com/brenner-tobias/addon-cloudflared/tree/v0.3.1 -[addon-doc-cloudflared]: https://github.com/brenner-tobias/addon-cloudflared/blob/v0.3.1/README.md +[addon-cloudflared]: https://github.com/brenner-tobias/addon-cloudflared/tree/v0.4.0 +[addon-doc-cloudflared]: https://github.com/brenner-tobias/addon-cloudflared/blob/v0.4.0/README.md [cloudflared-issue]: https://github.com/brenner-tobias/addon-cloudflared/issues -[cloudflared-version-shield]: https://img.shields.io/badge/version-v0.3.1-blue.svg +[cloudflared-version-shield]: https://img.shields.io/badge/version-v0.4.0-blue.svg [cloudflared-aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg [cloudflared-amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg [cloudflared-armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg diff --git a/cloudflared/CHANGELOG.md b/cloudflared/CHANGELOG.md index 038d563..1b45a9c 100644 --- a/cloudflared/CHANGELOG.md +++ b/cloudflared/CHANGELOG.md @@ -1,3 +1,9 @@ -## What's Changed -* Docu extension for quick tunnel (#30) @brenner-tobias -* First automatic deployment +## Whatโ€™s changed +## ๐Ÿš€ Enhancements + +- Add catch all service for external reverse proxies @brenner-tobias (#32) +- Add config check on start @brenner-tobias (#33) + +## ๐Ÿ“š Documentation + +- Documentation improvements @brenner-tobias \ No newline at end of file diff --git a/cloudflared/DOCS.md b/cloudflared/DOCS.md index f69336b..10b8b00 100644 --- a/cloudflared/DOCS.md +++ b/cloudflared/DOCS.md @@ -45,12 +45,15 @@ restart your HomeAssistant instance.** 1. (Optional) Change the `tunnel_name` add-on option (default: homeassistant). 1. (Optional) Add additional hosts to forward to in the `additional_hosts` array (see [detailed description below](#option-additional_hosts)). -1. (Optional) Add the `nginxproxymanager` flag to use the Cloudflare tunnel with +1. **Any existing DNS entries matching your defined `external_hostname` and `additional_hosts` + will be overridden at Cloudflare**. +1. (Optional) Add a `catch_all_service` to forward all other hosts to a URL + (see [detailed description below](#option-catch_all_service)). +1. (Optional) Add the `nginx_proxy_manager` flag to use the Cloudflare tunnel with the Nginxproxymanager add-on (see - [detailed description below](#option-nginxproxymanager)). -1. **Any existing DNS entries with your desired external hostname and additional - hosts will be overridden at Cloudflare**. -1. Start the "Cloudflare" add-on. + [detailed description below](#option-nginx_proxy_manager)). +1. Start the "Cloudflare" add-on. **Any existing DNS entries matching your defined + `external_hostname` and `additional_hosts` will be overridden at Cloudflare**. 1. Check the logs of the "Cloudflare" add-on and **follow the instruction to authenticate at Cloudflare**. You need to copy a URL from the logs and visit it to authenticate. @@ -59,6 +62,26 @@ restart your HomeAssistant instance.** ## Configuration +### Configuration.yaml + +Since HomeAssistant blocks requests from proxies / reverse proxies, you have to tell +your instance to allow requests from the Cloudflared Add-on. The add-on runs locally, +so HA has to trust the docker network. In order to do so, add the following lines +to your /config/configuration.yaml and restart your HA instance. +(if you need assistance changing the config, please follow the +[Advanced Configuration Tutorial][advancedconfiguration]): + +**Note**: _Remember to restart Home Assistance when the configuration is changed._ + +```yaml +http: + use_x_forwarded_for: true + trusted_proxies: + - 172.30.33.0/24 +``` + +### Add-on Configuration + **Note**: _Remember to restart the add-on when the configuration is changed._ Example basic add-on configuration: @@ -82,28 +105,12 @@ additional_hosts: - hostname: "website.example.com" service: "http://192.168.1.3:8080" disableChunkedEncoding: true -nginxproxymanager: true +nginx_proxy_manager: true log_level: "debug" ``` **Note**: _This is just an example, don't copy and paste it! Create your own!_ -### Configuration.yaml - -Since HomeAssistant blocks requests via proxies or reverse proxies, you have to tell -your instance to allow requests from the Cloudflared Add-On. The add-on runs locally, -so HA has to trust the docker network. In order to do so, add the following lines -to your /config/configuration.yaml and restart your HA instance. -(if you need assistance changing the config, please follow the -[Advanced Configuration Tutorial][advancedconfiguration]): - -```yaml -http: - use_x_forwarded_for: true - trusted_proxies: - - 172.30.33.0/24 -``` - ### Option: `additional_hosts` You can use the internal reverse proxy of Cloudflare Tunnel to define additional @@ -132,27 +139,53 @@ additional_hosts: ``` **Note**: _If you delete a hostname from the list, it will not be served -anymore (the request will run agains the default route). Nevertheless, -you should also manually delete the DNS entry from Cloudflare since it can not -be deleted by the Add-On._ +anymore. Nevertheless, you should also manually delete the DNS entry from +Cloudflare since it can not be deleted by the Add-on._ -### Option: `nginxproxymanager` +### Option: `catch_all_service` -If you want to use the Cloudflare Tunnel with the Add-On -[Nginx Proxy Manager][nginxproxymanager], you can do so by setting this option. +If you want to forward all requests from any hostnames not defined in the +`external_hostname` or the `additional_hosts`, you can use this option and +define a URL to forward to. For example, this can be used for reverse proxies. + +**Note**: _If you want to use the HA add-on [Nginx Proxy Manager][nginx_proxy_manager] +as reverse proxy, you should set the flag `nginx_proxy_manager` (see +[below](#option-nginx_proxy_manager)) and not use this option._ ```yaml -nginxproxymanager: true +catch_all_service: "http://192.168.1.100" ``` **Note**: _This will still route your defined `external_hostname`to HomeAssistant as well as any potential `additional_hosts` to where you defined in the config. -Any other incoming traffic will be routed to Nginx Proxy Manager._ +Any other incoming traffic will be routed to the defined service._ -In order to route multiple sub-domains through the tunnel, you have to create individual +In order to route hostnames through the tunnel, you have to create individual CNAME records in Cloudflare for all of them, pointing to your `external_hostname` -(or directly to the tunnel URL that you can get from the CNAME entry of -`external_hostname`). +or directly to the tunnel URL that you can get from the CNAME entry of +`external_hostname`. + +### Option: `nginx_proxy_manager` + +If you want to use the Cloudflare Tunnel with the Add-on +[Nginx Proxy Manager][nginx_proxy_manager], you can do so by setting this option. +It will automatically set the catch_all_service to the internal URL of Nginx Proxy +Manager. You do not have to add the option `catch_all_service` to your config (if +you add it anyways, it will be ignored). + +```yaml +nginx_proxy_manager: true +``` + +**Note**: _As with `catch_all_service`, this will still route your defined +`external_hostname`to HomeAssistant as well as any potential `additional_hosts` +to where you defined in the config. Any other incoming traffic will be routed +to Nginx Proxy Manager._ + +In order to route hostnames through the tunnel, you have to create individual +CNAME records in Cloudflare for all of them, pointing to your `external_hostname` +or directly to the tunnel URL that you can get from the CNAME entry of +`external_hostname`. Finally, you have to set-up your proxy hosts in Nginx Proxy Manager and forward them to wherever you like. @@ -263,6 +296,6 @@ SOFTWARE. [cloudflaretutorial]: https://support.cloudflare.com/hc/en-us/articles/360027989951-Getting-Started-with-Cloudflare [domainarticle]: https://www.linkedin.com/pulse/what-do-domain-name-how-get-one-free-tobias-brenner?trk=public_post-content_share-article [freenom]: https://freenom.com -[nginxproxymanager]: https://github.com/hassio-addons/addon-nginx-proxy-manager +[nginx_proxy_manager]: https://github.com/hassio-addons/addon-nginx-proxy-manager [tobias]: https://github.com/brenner-tobias [disablechunkedencoding]: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/configuration/configuration-file/ingress#disablechunkedencoding diff --git a/cloudflared/config.yaml b/cloudflared/config.yaml index 14932fd..bd30a2e 100644 --- a/cloudflared/config.yaml +++ b/cloudflared/config.yaml @@ -20,12 +20,13 @@ schema: - disableChunkedEncoding: bool? hostname: str service: str + catch_all_service: str? external_hostname: str log_level: list(trace|debug|info|notice|warning|error|fatal)? - nginxproxymanager: bool? + nginx_proxy_manager: bool? quick_tunnel: bool? reset_cloudflared_files: bool? tunnel_name: str slug: cloudflared url: https://github.com/brenner-tobias/addon-cloudflared/ -version: 0.3.1 +version: 0.4.0