Server
Turna can has server option, this option can be used for reverse proxy or load balancer with various middlewares.
Configuration
Highly inspired from traefik with small differences.
Turna has entrypoints
, http
and tcp
section. Under http section, there are middlewares
, routers
and tls
.
server:
# load_value: "x-server"
entrypoints:
web:
address: ":8080"
docker:
address: ":2375"
http:
middlewares: {}
routers:
test:
# entrypoints:
# - web
# tls: {}
path: /test
middlewares:
- test
- service
tcp:
middlewares:
ip:
ip_allow_list:
source_range:
- 127.0.0.1/32
redirect:
redirect:
address: "/var/run/docker.sock"
network: "unix"
routers:
mytcprouter:
entrypoints:
- docker
middlewares:
- ip
- redirect
EntryPoints
entrypoints are the connection point to the server. It can be usable with routers.
It is a map of entrypoint name and entrypoint configuration.
entrypoints:
web:
address: ":8080"
Routers
Routers combine entrypoints and middlewares with a path.
Path uses chi definitions.
routers:
test:
entrypoints:
- web
host: "example.com" # optional to use with host rule
path: /*
middlewares:
- test
- service
Middlewares
Middlewares are the main part of the server. It can be used for authentication, authorization, rate limiting, etc.
Declare middlewares under http.middlewares
section and use them in the routers with order.
TLS
TLS is the configuration for the TLS connection. It can be used with routers.
Don't mix entypoint for TLS and non-TLS routers. Serve will fail.
http:
middlewares: {}
routers: {}
tls:
default: # default tls certificate
- cert_file: ""
key_file: ""
To enable tls, add tls
section to the router.
routers:
test:
entrypoints:
- web
host: "example.com" # optional to use with host rule
path: /*
middlewares:
- test
- service
tls: {}