Verified against source code and enhanced with Docusaurus markdown features: Documentation Accuracy Fixes: - Fixed acme.md: Added "letsencrypt" as valid AUTOCONFIG value (was incorrectly shown as "-") - Added reference to ACME docs from environment-variable.md - Verified all features against actual implementation in /src Docusaurus Enhancements Added: - Admonitions (:::note, :::tip, :::warning, :::danger, :::info) for important callouts - Code block titles for all bash/yaml examples (e.g., title="Install EasyHAProxy") - Better structured warnings and notes for limitations - Improved formatting and readability throughout Files Enhanced: - kubernetes.md: Added info boxes, warnings, code titles - docker.md: Added limitation warnings, code titles - swarm.md: Added advantage tips, limitation warnings - acme.md: Fixed Let's Encrypt autoconfig, enhanced requirements with admonitions - ssl.md: Added code block titles for all examples - static.md: Added live reload tip, SSL certificate note - container-labels.md: Added definition explanation, code titles - limitations.md: Restructured with clear warnings and explanations - helm.md: Added warnings, code titles - microk8s.md: Added ingress controller warning, code titles - volumes.md: Added info box about volume purposes - other.md: Added code block titles - environment-variable.md: Added ACME reference note All changes verified against actual Python source code implementation.
129 lines
3.9 KiB
Markdown
129 lines
3.9 KiB
Markdown
---
|
|
sidebar_position: 4
|
|
---
|
|
|
|
# Static File
|
|
|
|
## Setup Docker EasyHAProxy
|
|
|
|
This method will use a static configuration, which is simpler and easier than creating a `haproxy.cfg`
|
|
|
|
You can use this configuration to set up external servers unrelated to docker or Kubernetes.
|
|
|
|
:::tip Live Reload
|
|
EasyHAProxy monitors this file for changes and automatically reconfigures HAProxy when any changes are detected.
|
|
:::
|
|
|
|
First, create a YAML configuration:
|
|
|
|
```yaml
|
|
stats:
|
|
username: admin
|
|
password: password
|
|
port: 1936 # Optional (default 1936)
|
|
|
|
customerrors: true # Optional (default false)
|
|
|
|
ssl_mode: default
|
|
|
|
logLevel:
|
|
haproxy: INFO
|
|
|
|
certbot: {
|
|
"email": "acme@example.org"
|
|
}
|
|
|
|
easymapping:
|
|
- port: 80
|
|
hosts:
|
|
host1.com.br:
|
|
containers:
|
|
- container:5000
|
|
certbot: true
|
|
redirect_ssl: true
|
|
host2.com.br:
|
|
containers:
|
|
- other:3000
|
|
redirect:
|
|
www.host1.com.br: http://host1.com.br
|
|
|
|
- port: 443
|
|
hosts:
|
|
host1.com.br:
|
|
containers:
|
|
- container:80
|
|
redirect_ssl: false
|
|
ssl: true
|
|
|
|
- port: 8080
|
|
hosts:
|
|
host3.com.br:
|
|
containers:
|
|
- domain:8181
|
|
```
|
|
|
|
Then map this file to `/etc/haproxy/static/config.yml` in your EasyHAProxy container:
|
|
|
|
```bash title="Run EasyHAProxy with static configuration"
|
|
docker run -d \
|
|
--name easy-haproxy-container \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
-v /my/static/:/etc/haproxy/static/ \
|
|
-e EASYHAPROXY_DISCOVER="static" \
|
|
# + Environment Variables \
|
|
-p 80:80 \
|
|
-p 443:443 \
|
|
-p 1936:1936 \
|
|
--network easyhaproxy \
|
|
byjg/easy-haproxy
|
|
```
|
|
|
|
You can find other informations on [docker label configuration](container-labels.md) and [environment variable guide](environment-variable.md)
|
|
|
|
## Yaml Definition
|
|
|
|
```yaml
|
|
stats:
|
|
username: admin # Optional (default "admin")
|
|
password: password # If stats or stats.password is omitted, stats will be public with no password
|
|
port: 1936 # Optional (default 1936)
|
|
|
|
customerrors: true # Optional (default false)
|
|
|
|
ssl_mode: default # Optional
|
|
|
|
logLevel:
|
|
certbot: DEBUG # Optional (default: DEBUG). Can be: TRACE,DEBUG,INFO,WARN,ERROR,FATAL
|
|
easyhaproxy: DEBUG # Optional (default: DEBUG). Can be: TRACE,DEBUG,INFO,WARN,ERROR,FATAL
|
|
haproxy: INFO # Optional (default: INFO). Can be: TRACE,DEBUG,INFO,WARN,ERROR,FATAL
|
|
|
|
certbot:
|
|
email: "acme@example.org" # If email is defined enable ACME/Certbot
|
|
autoconfig: "" # If empty use letsencrypt, otherwise try to set the CA defined.
|
|
eab_hmac_key: "" # If required by the CA, set here.
|
|
eab_kid: "" # If required by the CA, set here.
|
|
server: False # If empty/False uses Letsencrypt, otherwise the CA Endpoint defined here
|
|
retry_count: 60 # If the certificate reaches the Rate Limit, try again after 'n' iterations.
|
|
}
|
|
|
|
easymapping:
|
|
- port: 80 # Listen port
|
|
mode: http # Optional. Default `http`. Can be http or tcp
|
|
hosts:
|
|
host1.com.br: # Hostname
|
|
containers:
|
|
- container:5000 # Endpoints of the hostname above (ip, dns, container, etc)
|
|
certbot: true # Optional. it will request a certbot certificate. Needs certbot.email set.
|
|
redirect_ssl: true # Optional. It will redirect this site to it SSL.
|
|
ssl: true # Optional. Inform this port will listen to SSL, instead of HTTP
|
|
clone_to_ssl: true # Optional. Default False. You clone these hosts to its equivalent SSL.
|
|
redirect:
|
|
www.host1.com.br: http://host1.com.br
|
|
```
|
|
|
|
:::note SSL Certificates in Static Mode
|
|
The only way to provide SSL certificates in static configuration mode is to map the certificates to EasyHAProxy as a docker volume. Refer to the [SSL documentation](ssl.md) to learn how to configure this.
|
|
:::
|
|
|
|
----
|
|
[Open source ByJG](http://opensource.byjg.com)
|