Merge pull request 'reverse-proxy.md: Added healthcheck examples' (#505) from jpds/garage:doc-healthchecks into main
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #505
This commit is contained in:
commit
ae0934e018
1 changed files with 102 additions and 30 deletions
|
@ -168,40 +168,65 @@ Here is [a basic configuration file](https://doc.traefik.io/traefik/https/acme/#
|
||||||
|
|
||||||
### Add Garage service
|
### Add Garage service
|
||||||
|
|
||||||
To add Garage on Traefik you should declare a new service using its IP address (or hostname) and port:
|
To add Garage on Traefik you should declare two new services using its IP
|
||||||
|
address (or hostname) and port, these are used for the S3, and web components
|
||||||
|
of Garage:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[http.services]
|
[http.services]
|
||||||
[http.services.my_garage_service.loadBalancer]
|
[http.services.garage-s3-service.loadBalancer]
|
||||||
[[http.services.my_garage_service.loadBalancer.servers]]
|
[[http.services.garage-s3-service.loadBalancer.servers]]
|
||||||
url = "http://xxx.xxx.xxx.xxx"
|
url = "http://xxx.xxx.xxx.xxx"
|
||||||
port = 3900
|
port = 3900
|
||||||
|
|
||||||
|
[http.services.garage-web-service.loadBalancer]
|
||||||
|
[[http.services.garage-web-service.loadBalancer.servers]]
|
||||||
|
url = "http://xxx.xxx.xxx.xxx"
|
||||||
|
port = 3902
|
||||||
```
|
```
|
||||||
|
|
||||||
It's possible to declare multiple Garage servers as back-ends:
|
It's possible to declare multiple Garage servers as back-ends:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[http.services]
|
[http.services]
|
||||||
[[http.services.my_garage_service.loadBalancer.servers]]
|
[[http.services.garage-s3-service.loadBalancer.servers]]
|
||||||
url = "http://xxx.xxx.xxx.xxx"
|
url = "http://xxx.xxx.xxx.xxx"
|
||||||
port = 3900
|
port = 3900
|
||||||
[[http.services.my_garage_service.loadBalancer.servers]]
|
[[http.services.garage-s3-service.loadBalancer.servers]]
|
||||||
url = "http://yyy.yyy.yyy.yyy"
|
url = "http://yyy.yyy.yyy.yyy"
|
||||||
port = 3900
|
port = 3900
|
||||||
[[http.services.my_garage_service.loadBalancer.servers]]
|
[[http.services.garage-s3-service.loadBalancer.servers]]
|
||||||
url = "http://zzz.zzz.zzz.zzz"
|
url = "http://zzz.zzz.zzz.zzz"
|
||||||
port = 3900
|
port = 3900
|
||||||
|
|
||||||
|
[[http.services.garage-web-service.loadBalancer.servers]]
|
||||||
|
url = "http://xxx.xxx.xxx.xxx"
|
||||||
|
port = 3902
|
||||||
|
[[http.services.garage-web-service.loadBalancer.servers]]
|
||||||
|
url = "http://yyy.yyy.yyy.yyy"
|
||||||
|
port = 3902
|
||||||
|
[[http.services.garage-web-service.loadBalancer.servers]]
|
||||||
|
url = "http://zzz.zzz.zzz.zzz"
|
||||||
|
port = 3902
|
||||||
```
|
```
|
||||||
|
|
||||||
Traefik can remove unhealthy servers automatically with [a health check configuration](https://doc.traefik.io/traefik/routing/services/#health-check):
|
Traefik can remove unhealthy servers automatically with [a health check configuration](https://doc.traefik.io/traefik/routing/services/#health-check):
|
||||||
|
|
||||||
```
|
```
|
||||||
[http.services]
|
[http.services]
|
||||||
[http.services.my_garage_service.loadBalancer]
|
[http.services.garage-s3-service.loadBalancer]
|
||||||
[http.services.my_garage_service.loadBalancer.healthCheck]
|
[http.services.garage-s3-service.loadBalancer.healthCheck]
|
||||||
path = "/"
|
path = "/health"
|
||||||
interval = "60s"
|
port = "3903"
|
||||||
timeout = "5s"
|
#interval = "15s"
|
||||||
|
#timeout = "2s"
|
||||||
|
|
||||||
|
[http.services.garage-web-service.loadBalancer]
|
||||||
|
[http.services.garage-web-service.loadBalancer.healthCheck]
|
||||||
|
path = "/health"
|
||||||
|
port = "3903"
|
||||||
|
#interval = "15s"
|
||||||
|
#timeout = "2s"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Adding a website
|
### Adding a website
|
||||||
|
@ -210,10 +235,15 @@ To add a new website, add the following declaration to your Traefik configuratio
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[http.routers]
|
[http.routers]
|
||||||
|
[http.routers.garage-s3]
|
||||||
|
rule = "Host(`s3.example.org`)"
|
||||||
|
service = "garage-s3-service"
|
||||||
|
entryPoints = ["websecure"]
|
||||||
|
|
||||||
[http.routers.my_website]
|
[http.routers.my_website]
|
||||||
rule = "Host(`yoururl.example.org`)"
|
rule = "Host(`yoururl.example.org`)"
|
||||||
service = "my_garage_service"
|
service = "garage-web-service"
|
||||||
entryPoints = ["web"]
|
entryPoints = ["websecure"]
|
||||||
```
|
```
|
||||||
|
|
||||||
Enable HTTPS access to your website with the following configuration section ([documentation](https://doc.traefik.io/traefik/https/overview/)):
|
Enable HTTPS access to your website with the following configuration section ([documentation](https://doc.traefik.io/traefik/https/overview/)):
|
||||||
|
@ -226,7 +256,7 @@ Enable HTTPS access to your website with the following configuration section ([d
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
### Adding gzip compression
|
### Adding compression
|
||||||
|
|
||||||
Add the following configuration section [to compress response](https://doc.traefik.io/traefik/middlewares/http/compress/) using [gzip](https://developer.mozilla.org/en-US/docs/Glossary/GZip_compression) before sending them to the client:
|
Add the following configuration section [to compress response](https://doc.traefik.io/traefik/middlewares/http/compress/) using [gzip](https://developer.mozilla.org/en-US/docs/Glossary/GZip_compression) before sending them to the client:
|
||||||
|
|
||||||
|
@ -234,10 +264,10 @@ Add the following configuration section [to compress response](https://doc.traef
|
||||||
[http.routers]
|
[http.routers]
|
||||||
[http.routers.my_website]
|
[http.routers.my_website]
|
||||||
...
|
...
|
||||||
middlewares = ["gzip_compress"]
|
middlewares = ["compression"]
|
||||||
...
|
...
|
||||||
[http.middlewares]
|
[http.middlewares]
|
||||||
[http.middlewares.gzip_compress.compress]
|
[http.middlewares.compression.compress]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Add caching response
|
### Add caching response
|
||||||
|
@ -262,27 +292,54 @@ Traefik's caching middleware is only available on [entreprise version](https://d
|
||||||
entryPoint = "web"
|
entryPoint = "web"
|
||||||
|
|
||||||
[http.routers]
|
[http.routers]
|
||||||
|
[http.routers.garage-s3]
|
||||||
|
rule = "Host(`s3.example.org`)"
|
||||||
|
service = "garage-s3-service"
|
||||||
|
entryPoints = ["websecure"]
|
||||||
|
|
||||||
[http.routers.my_website]
|
[http.routers.my_website]
|
||||||
rule = "Host(`yoururl.example.org`)"
|
rule = "Host(`yoururl.example.org`)"
|
||||||
service = "my_garage_service"
|
service = "garage-web-service"
|
||||||
middlewares = ["gzip_compress"]
|
middlewares = ["compression"]
|
||||||
entryPoints = ["websecure"]
|
entryPoints = ["websecure"]
|
||||||
|
|
||||||
[http.services]
|
[http.services]
|
||||||
[http.services.my_garage_service.loadBalancer]
|
[http.services.garage-s3-service.loadBalancer]
|
||||||
[http.services.my_garage_service.loadBalancer.healthCheck]
|
[http.services.garage-s3-service.loadBalancer.healthCheck]
|
||||||
path = "/"
|
path = "/health"
|
||||||
interval = "60s"
|
port = "3903"
|
||||||
timeout = "5s"
|
#interval = "15s"
|
||||||
[[http.services.my_garage_service.loadBalancer.servers]]
|
#timeout = "2s"
|
||||||
|
|
||||||
|
[http.services.garage-web-service.loadBalancer]
|
||||||
|
[http.services.garage-web-service.loadBalancer.healthCheck]
|
||||||
|
path = "/health"
|
||||||
|
port = "3903"
|
||||||
|
#interval = "15s"
|
||||||
|
#timeout = "2s"
|
||||||
|
|
||||||
|
[[http.services.garage-s3-service.loadBalancer.servers]]
|
||||||
url = "http://xxx.xxx.xxx.xxx"
|
url = "http://xxx.xxx.xxx.xxx"
|
||||||
[[http.services.my_garage_service.loadBalancer.servers]]
|
port = 3900
|
||||||
|
[[http.services.garage-s3-service.loadBalancer.servers]]
|
||||||
url = "http://yyy.yyy.yyy.yyy"
|
url = "http://yyy.yyy.yyy.yyy"
|
||||||
[[http.services.my_garage_service.loadBalancer.servers]]
|
port = 3900
|
||||||
|
[[http.services.garage-s3-service.loadBalancer.servers]]
|
||||||
url = "http://zzz.zzz.zzz.zzz"
|
url = "http://zzz.zzz.zzz.zzz"
|
||||||
|
port = 3900
|
||||||
|
|
||||||
|
[[http.services.garage-web-service.loadBalancer.servers]]
|
||||||
|
url = "http://xxx.xxx.xxx.xxx"
|
||||||
|
port = 3902
|
||||||
|
[[http.services.garage-web-service.loadBalancer.servers]]
|
||||||
|
url = "http://yyy.yyy.yyy.yyy"
|
||||||
|
port = 3902
|
||||||
|
[[http.services.garage-web-service.loadBalancer.servers]]
|
||||||
|
url = "http://zzz.zzz.zzz.zzz"
|
||||||
|
port = 3902
|
||||||
|
|
||||||
[http.middlewares]
|
[http.middlewares]
|
||||||
[http.middlewares.gzip_compress.compress]
|
[http.middlewares.compression.compress]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Caddy
|
## Caddy
|
||||||
|
@ -291,15 +348,30 @@ Your Caddy configuration can be as simple as:
|
||||||
|
|
||||||
```caddy
|
```caddy
|
||||||
s3.garage.tld, *.s3.garage.tld {
|
s3.garage.tld, *.s3.garage.tld {
|
||||||
reverse_proxy localhost:3900 192.168.1.2:3900 example.tld:3900
|
reverse_proxy localhost:3900 192.168.1.2:3900 example.tld:3900 {
|
||||||
|
health_uri /health
|
||||||
|
health_port 3903
|
||||||
|
#health_interval 15s
|
||||||
|
#health_timeout 5s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*.web.garage.tld {
|
*.web.garage.tld {
|
||||||
reverse_proxy localhost:3902 192.168.1.2:3902 example.tld:3902
|
reverse_proxy localhost:3902 192.168.1.2:3902 example.tld:3902 {
|
||||||
|
health_uri /health
|
||||||
|
health_port 3903
|
||||||
|
#health_interval 15s
|
||||||
|
#health_timeout 5s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
admin.garage.tld {
|
admin.garage.tld {
|
||||||
reverse_proxy localhost:3903
|
reverse_proxy localhost:3903 {
|
||||||
|
health_uri /health
|
||||||
|
health_port 3903
|
||||||
|
#health_interval 15s
|
||||||
|
#health_timeout 5s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue