mirror of
https://github.com/caddyserver/caddy.git
synced 2025-07-09 03:04:57 -04:00
Added a Caddyfile example for a simple reverse proxy
parent
543ae0e03b
commit
274dd5ad17
@ -114,7 +114,7 @@ encode gzip
|
||||
php_fastcgi unix//path/to/php.sock
|
||||
file_server
|
||||
```
|
||||
The converted equivalant (`caddy adapt --config /path/to/Caddyfile --pretty_) in JSON looks like this:
|
||||
The converted equivalant (`caddy adapt --config /path/to/Caddyfile --pretty`) in JSON looks like this:
|
||||
```
|
||||
{
|
||||
"apps": {
|
||||
@ -203,4 +203,87 @@ The converted equivalant (`caddy adapt --config /path/to/Caddyfile --pretty_) in
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
## Reverse proxy to HTTP golang servers on port 8080 with automatic TLS and health checks
|
||||
|
||||
Configuring Caddy as a reverse proxy to HTTP golang servers on port 8080 with automatic TLS and health checks can look like this:
|
||||
```
|
||||
yourdomain.com, www.yourdomain.com
|
||||
|
||||
reverse_proxy / {
|
||||
to 192.101.153.159:8080 192.118.109.166:8080
|
||||
health_path /health
|
||||
health_status 200
|
||||
transport http {
|
||||
read_buffer 4096
|
||||
}
|
||||
}
|
||||
```
|
||||
The converted equivalant (`caddy adapt --config /path/to/Caddyfile --pretty`) in JSON looks like this:
|
||||
```
|
||||
{
|
||||
"apps":{
|
||||
"http":{
|
||||
"servers":{
|
||||
"srv0":{
|
||||
"listen":[
|
||||
":443"
|
||||
],
|
||||
"routes":[
|
||||
{
|
||||
"match":[
|
||||
{
|
||||
"host":[
|
||||
"yourdomain.com",
|
||||
"www.yourdomain.com"
|
||||
]
|
||||
}
|
||||
],
|
||||
"handle":[
|
||||
{
|
||||
"handler":"subroute",
|
||||
"routes":[
|
||||
{
|
||||
"handle":[
|
||||
{
|
||||
"handler":"reverse_proxy",
|
||||
"health_checks":{
|
||||
"active":{
|
||||
"expect_status":2,
|
||||
"path":"/health"
|
||||
}
|
||||
},
|
||||
"transport":{
|
||||
"protocol":"http",
|
||||
"read_buffer_size":4096
|
||||
},
|
||||
"upstreams":[
|
||||
{
|
||||
"dial":"192.101.153.159:8080"
|
||||
},
|
||||
{
|
||||
"dial":"192.118.109.166:8080"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"match":[
|
||||
{
|
||||
"path":[
|
||||
"/"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
**Note:** do not forget to set up health handlers for the golang webservers returning an HTTP 200 response or Caddy 2 will fail the health check and deem the node unreachable.
|
Loading…
x
Reference in New Issue
Block a user