| 1 |
== Proxying RadSec with Traefik |
| 2 |
|
| 3 |
This section shows how to configure Traefik to proxy RadSec connections. You |
| 4 |
should skip this section if you are not using Traefik as your proxy. |
| 5 |
|
| 6 |
Installing Traefik is beyond the scope of this guide. It is typically installed |
| 7 |
as a service mesh router within a Docker or Kubernetes environment using |
| 8 |
offical Docker images. |
| 9 |
|
| 10 |
Traefik configuration has two components of interest: |
| 11 |
|
| 12 |
* Static configuration: Defines "entrypoints" on which Traefik listens for connections. |
| 13 |
* Dynamic configuration: Defines backend service components and the routing policy. |
| 14 |
|
| 15 |
Traefik supports a number of providers of dynamic configuration data for the |
| 16 |
router and service definitions. For demonstration purposes the files provider |
| 17 |
is used here, however you can switch to another provide once you have things |
| 18 |
working using this method. |
| 19 |
|
| 20 |
The static configuration can be provided by starting Traefik with the following |
| 21 |
arguments: |
| 22 |
|
| 23 |
.Example Traefik static configuration |
| 24 |
===================================== |
| 25 |
|
| 26 |
traefik \ |
| 27 |
--log.level=DEBUG \ |
| 28 |
--providers.file.filename=/etc/traefik/dynamic_config.yml |
| 29 |
--providers.file.watch=true |
| 30 |
--entryPoints.radsec.address=:2083 |
| 31 |
|
| 32 |
===================================== |
| 33 |
|
| 34 |
Note that a `radsec` entrypoint is defined to listen on port 2083 and that a |
| 35 |
static `file` provider is used to defined the dynamic services. |
| 36 |
|
| 37 |
The backend for RadSec should be defined in this file as follows: |
| 38 |
|
| 39 |
.Example Traefik dynamic configuration |
| 40 |
====================================== |
| 41 |
|
| 42 |
tcp: |
| 43 |
routers: |
| 44 |
radsec-router: |
| 45 |
entryPoints: |
| 46 |
- radsec |
| 47 |
rule: "HostSNI(`*`)" |
| 48 |
service: "radsec-service" |
| 49 |
tls: |
| 50 |
passthrough: true |
| 51 |
services: |
| 52 |
radsec-service: |
| 53 |
loadBalancer: |
| 54 |
servers: |
| 55 |
- address: "172.23.0.3:2083" |
| 56 |
|
| 57 |
====================================== |
| 58 |
|
| 59 |
Note the `passthrough: true` directive under `tls:` which tells Treafik not to |
| 60 |
attempt TLS termination which it would otherwise perform for all incoming TLS |
| 61 |
connections. We require that the connection is passed through from the RadSec |
| 62 |
client to the RadSec server without being reterminated since the end client's |
| 63 |
certificate is authenticated by the RadSec server and many be used for |
| 64 |
policy decisions. |
| 65 |
|
| 66 |
|
| 67 |
=== Testing RadSec connectivity via Traefik |
| 68 |
|
| 69 |
Now amend the test RadSec client so that instead of making connections directly |
| 70 |
to the RadSec server it makes them via Traefik. |
| 71 |
|
| 72 |
On `radseccli` amend `/etc/raddb/sites-enabled/tls` and set the IP address to |
| 73 |
that of the `traefik` host. |
| 74 |
|
| 75 |
.Example updated test client homeserver configuration |
| 76 |
===================================================== |
| 77 |
|
| 78 |
home_server tls { |
| 79 |
ipaddr = 172.23.0.5 # Updated from radsecsvr to traefik |
| 80 |
... |
| 81 |
} |
| 82 |
|
| 83 |
===================================================== |
| 84 |
|
| 85 |
Restart the debug mode session: |
| 86 |
|
| 87 |
[source,shell] |
| 88 |
---- |
| 89 |
radiusd -X |
| 90 |
---- |
| 91 |
|
| 92 |
Perform a test authentication: |
| 93 |
|
| 94 |
[source,shell] |
| 95 |
---- |
| 96 |
echo "User-Name = bob" | radclient 127.0.0.1 auth testing123 |
| 97 |
---- |
| 98 |
|
| 99 |
If the test client is able to successfully establish the RadSec connection via |
| 100 |
Traefik and the RadSec server replies with an Access-Accept response then the |
| 101 |
output will be as follows: |
| 102 |
|
| 103 |
.Example output from radclient |
| 104 |
============================== |
| 105 |
|
| 106 |
Sent Access-Request Id 252 from 0.0.0.0:50118 to 127.0.0.1:1812 length 27 |
| 107 |
Received Access-Accept Id 252 from 127.0.0.1:1812 to 127.0.0.1:50118 length 39 |
| 108 |
|
| 109 |
============================== |
| 110 |
|
| 111 |
Traefik should also log a message that indicates that the connection was |
| 112 |
proxied, such as the following: |
| 113 |
|
| 114 |
.Example output from Traefik |
| 115 |
============================ |
| 116 |
|
| 117 |
time="..." level=debug msg="Handling connection from 172.23.0.2:57367" |
| 118 |
|
| 119 |
============================ |
| 120 |
|
| 121 |
Any other output from radclient or Traefik indicates that there is a problem |
| 122 |
with the Traefik configuration or that FreeRADIUS is not accepting connection |
| 123 |
from the `traefik` host, which must be solved before continuing. |
| 124 |
|
| 125 |
Once proxied connections are working we are ready to |
| 126 |
xref:protocols/proxy/enable_proxy_protocol.adoc[enable the PROXY Protocol] on |
| 127 |
both Traefik and the RadSec server. |
| 128 |
|