{"id":22717543,"url":"https://github.com/lemariva/haproxy-certbot","last_synced_at":"2025-10-29T09:32:49.803Z","repository":{"id":109048808,"uuid":"440953849","full_name":"lemariva/haproxy-certbot","owner":"lemariva","description":"A Dockerized service that adds SSL layer (reverse proxy) and automatically renews the SSL certificate when needed.","archived":false,"fork":false,"pushed_at":"2024-12-24T23:58:21.000Z","size":17,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T02:56:03.413Z","etag":null,"topics":["certificate","docker","home-assistant","https","letsencrypt","reverse-proxy","ssl","tls"],"latest_commit_sha":null,"homepage":"https://lemariva.com/blog/2022/01/home-assistant-help-tips-tricks-diy-smart-home","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemariva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-22T18:45:34.000Z","updated_at":"2024-12-24T23:58:24.000Z","dependencies_parsed_at":"2025-02-05T00:35:33.876Z","dependency_job_id":null,"html_url":"https://github.com/lemariva/haproxy-certbot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lemariva/haproxy-certbot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2Fhaproxy-certbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2Fhaproxy-certbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2Fhaproxy-certbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2Fhaproxy-certbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemariva","download_url":"https://codeload.github.com/lemariva/haproxy-certbot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2Fhaproxy-certbot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266673584,"owners_count":23966377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["certificate","docker","home-assistant","https","letsencrypt","reverse-proxy","ssl","tls"],"created_at":"2024-12-10T14:11:04.721Z","updated_at":"2025-10-29T09:32:44.758Z","avatar_url":"https://github.com/lemariva.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HAPROXY and Let's Encrypt\n\nHAProxy is a free, very fast, and reliable reverse-proxy offering high availability, load balancing, and proxying for TCP and HTTP-based applications. \nThis repository combines HAProxy and Let's Encrypt to provide high-performance SSL termination, allowing you to encrypt and decrypt traffic to your HTTP-based application. Let's Encrypt is a certification authority that provides simple and free SSL certificates. The CA is embedded in all relevant browsers so that you can secure your websites with Let's Encrypt. And all at no cost.\n\nLet's start with some explanation about how HTTPS works: The encryption and security functionalities for HTTP are implemented through the Transport Layer Security (TLS) protocol. TLS defines a standard way to secure any network communication channel. The idea is that when a client (browser, application, etc.) establishes a connection with a server and requests an encrypted connection, the server responds with its SSL certificate. This certificate acts as an identification for the server (includes the name of the server and the domain) and is signed by a certificate authority (CA). If the client knows and trusts the CA, they can confirm that the certificate signature comes from the entity, and then they can be sure that the server is legitimate.\n\nAfter verifying the certificate, the client creates an encryption key to use for communicating with the server. This key is sent securely to the server (encrypted with the public key included with the server's certificate). The server, which has the private key (that corresponds to the public key), can decrypt the packet and obtain the key. From this point on, all traffic is encrypted with the key that only the client and server know.\n\nTherefore, we need two items:\n\n* a server certificate, which includes a public key and is signed by a CA,\n* and a private key that goes with the public key included in the certificate.\n\nTo request a certificate from a CA, the entity is going to verify that you are in control of your server and domain. This verification depends on the CA, and if the server passes the verification, then the CA will issue a certificate for the server with its signature that you can install. This certificate lasts for a year. However, most CAs charge money for these certificates. But, in recent years there are more and more CAs that offer them for free. The most popular is Let's Encrypt.\n\nTherefore, you can use this Docker image to add an SSL layer to your HTTP-based applications. The following steps are for Home Assistant (HA).\n\n## DIY\n\n### Pull the Docker Image\nYou can build the Docker image (check the files inside `docker-stack`) or you can pull it from the Dockerhub register:\n```\ndocker pull lemariva/haproxy-certbot:1.1.2-SNAPSHOT\n```\nTo start the service, `docker-compose` must be installed. Otherwise, you need to configure all the variables and settings that you can find inside the `docker-compose.yml` file.\n\n### Configure the Docker Service\nBut, before starting the service, edit `SERVICE_IP` and `PORT_IP` variables inside the file `docker-compose.yml`. Both should point to the service that you are forwarding. In my case, that is:\n```\nSERVICE_IP: 192.168.178.161\nSERVICE_PORT: 8123\n```\nThe IP `192.168.178.161` and port `8123` points to my Raspberry Pi address and the standard port of HA, respectively.\n\nThen, you can start the service by typing the following:\n```\ncd orchestration\ndocker-compose up -d\n```\n\n### Configure HA\nIf you are running HA with version greater than v2021.7.0, you will get a \"400 Bad Request\" error when I tried to access HA via the HTTP/HTTPS address. A breaking change was added to this version and if you are running a proxy you need to add to the `configuration.yaml` the following:\n```\n# proxy\nhttp:\n  use_x_forwarded_for: true\n  trusted_proxies:\n    - \u003c\u003cPROXY_IP\u003e\u003e\n```\nIf your proxy is running on another machine, you need to change `\u003c\u003cPROXY_IP\u003e\u003e` with the IP address of that machine. But, if you are running the proxy on the same machine that HA is running, you need to change `\u003c\u003cPROXY_IP\u003e\u003e` with the Docker internal IP of the container. You can get that by typing the following:\n```\ndocker container inspect `docker ps -aqf \"name=haproxy-certbot\"` | grep \"\\\"IPAddress\\\": \\\"1\"\n```\nNote: this works if you didn't change the name to the container (`LOAD_BALANCER_NAME`) inside the `.env` file. Otherwise, you need to change that.\nYou get something like this:\n```\npi@homeassistant:~ $ docker container inspect `docker ps -aqf \"name=haproxy-certbot\"` | grep \"\\\"IPAddress\\\": \\\"1\"\n                    \"IPAddress\": \"172.26.0.2\",\n```\nThe `172.26.0.2` is the IP address that you need.\n\n### Get the first certificate\nTo get a certificate from Let's Encrypt, you need to forward the port `80` and `443` of your computer to the Internet and you need a URL pointing to your router (basically a domain name). Internet providers usually change the IP address that you get every 24 hours. Thus, you need to get a dynamic DNS service. I use [NoIP](https://www.noip.com?fpr=y842j), it's free but you need to confirm your host every 30 days (no big deal). If you are thinking of buying a subscription, you can get a 5 dollars discount using the promo code `REFER5`, After opening the ports on your router and getting a domain name thats point to your router, you can get the first certificate from Let's Encrypt. To do that, you need to get inside the Docker container using:\n```\ndocker container exec -it `docker ps -aqf \"name=haproxy-certbot\"` /bin/bash\n```\nand run the following commands:\n```\n/usr/bin/certbot certonly -c /usr/local/etc/letsencrypt/cli.ini --agree-tos --email \u003c\u003cYOUR_EMAIL\u003e\u003e --domains \u003c\u003cYOUR_DOMAIN\u003e\u003e\n\nhaproxy-refresh\n```\nReplace `\u003c\u003cYOUR_EMAIL\u003e\u003e` and `\u003c\u003cYOUR_DOMAIN\u003e\u003e` with your valid email address and the domain that points to your router. If everything goes as planned, you will get a valid SSL certificate for your HA system.\n\nThen, you can integrate your HA to e.g. Google Home Assistant following the steps in [this tutorial](https://www.home-assistant.io/integrations/google_assistant/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2Fhaproxy-certbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemariva%2Fhaproxy-certbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2Fhaproxy-certbot/lists"}