| 1 |
== Proxying RadSec with HAproxy |
| 2 |
|
| 3 |
This section shows how to configure HAproxy to proxy RadSec connections. |
| 4 |
|
| 5 |
The following steps should be performed on the `haproxy` host, unless otherwise |
| 6 |
stated. |
| 7 |
|
| 8 |
Install the HAproxy package supplied with the OS distribution: |
| 9 |
|
| 10 |
[source,shell] |
| 11 |
---- |
| 12 |
yum install haproxy |
| 13 |
---- |
| 14 |
|
| 15 |
Stop the haproxy service: |
| 16 |
|
| 17 |
[source,shell] |
| 18 |
---- |
| 19 |
service haproxy stop |
| 20 |
---- |
| 21 |
|
| 22 |
Modify the haproxy configuration (typically `/etc/haproxy/haproxy.conf`) so |
| 23 |
that it includes new frontend and backend configuration for the radsec service: |
| 24 |
|
| 25 |
.Example minimal HAproxy configuration |
| 26 |
====================================== |
| 27 |
|
| 28 |
global |
| 29 |
maxconn 100 |
| 30 |
defaults |
| 31 |
mode tcp |
| 32 |
timeout connect 10s |
| 33 |
timeout client 30s |
| 34 |
timeout server 30s |
| 35 |
frontend radsec_fe |
| 36 |
bind *:2083 |
| 37 |
default_backend radsec_be |
| 38 |
backend radsec_be |
| 39 |
balance roundrobin |
| 40 |
server radsecsvr 172.23.0.3:2083 |
| 41 |
|
| 42 |
====================================== |
| 43 |
|
| 44 |
Note the `mode tcp` directive which tells HAproxy to act as a Layer 4 |
| 45 |
proxy, so that it doesn't attempt to perform SSL termination or |
| 46 |
decode the RADIUS protocol. |
| 47 |
|
| 48 |
[NOTE] |
| 49 |
==== |
| 50 |
The above example is a minimal configuration. In practise you will want to |
| 51 |
retain many of the HAproxy configuration items already present in the |
| 52 |
configuration (e.g. `log`, `chroot`, `user`, `group`), but these vary across |
| 53 |
distributions. Other HTTP-related options that may already exist in the |
| 54 |
configuration will conflict with `mode tcp` (Layer 4 proxying) and should be |
| 55 |
removed if HAproxy complains about them. |
| 56 |
|
| 57 |
However, you should first get things working with the minimal |
| 58 |
configuration which is known to work, and then make customisations. |
| 59 |
If you start off with a complex configuration, then there may be a |
| 60 |
large number of things which are broken, and debugging them all will |
| 61 |
be difficult. Start simple, and then add complexity! |
| 62 |
==== |
| 63 |
|
| 64 |
Restart the haproxy service in foreground mode for debugging purposes: |
| 65 |
|
| 66 |
[source,shell] |
| 67 |
---- |
| 68 |
haproxy -f /etc/haproxy/haproxy.cfg -db |
| 69 |
---- |
| 70 |
|
| 71 |
|
| 72 |
=== Testing RadSec connectivity via HAproxy |
| 73 |
|
| 74 |
Now edit the test RadSec client, so that instead of making connections directly |
| 75 |
to the RadSec server it makes connections to the HAproxy server. |
| 76 |
|
| 77 |
On `radseccli` edit the `/etc/raddb/sites-enabled/tls` file, and set |
| 78 |
the IP address to the address of the `haproxy` host. |
| 79 |
|
| 80 |
.Example updated test client homeserver configuration |
| 81 |
===================================================== |
| 82 |
|
| 83 |
home_server tls { |
| 84 |
ipaddr = 172.23.0.4 # Updated from radsecsvr to haproxy |
| 85 |
... |
| 86 |
} |
| 87 |
|
| 88 |
===================================================== |
| 89 |
|
| 90 |
Restart the debug mode session: |
| 91 |
|
| 92 |
[source,shell] |
| 93 |
---- |
| 94 |
radiusd -X |
| 95 |
---- |
| 96 |
|
| 97 |
Perform a test authentication: |
| 98 |
|
| 99 |
[source,shell] |
| 100 |
---- |
| 101 |
echo "User-Name = bob" | radclient 127.0.0.1 auth testing123 |
| 102 |
---- |
| 103 |
|
| 104 |
If the test client is able to successfully establish the RadSec |
| 105 |
connection via HAproxy, and the RadSec server replies with an |
| 106 |
Access-Accept response, then the output will be as follows: |
| 107 |
|
| 108 |
.Expected output from radclient |
| 109 |
=============================== |
| 110 |
|
| 111 |
Sent Access-Request Id 252 from 0.0.0.0:50118 to 127.0.0.1:1812 length 27 |
| 112 |
Received Access-Accept Id 252 from 127.0.0.1:1812 to 127.0.0.1:50118 length 39 |
| 113 |
|
| 114 |
=============================== |
| 115 |
|
| 116 |
HAproxy should also log a message that indicates that the connection was |
| 117 |
proxied, such as the following: |
| 118 |
|
| 119 |
.Expected output from HAproxy |
| 120 |
============================= |
| 121 |
|
| 122 |
<150>...: Connect from 172.23.0.2:50087 to 172.23.0.4:2083 (radius_fr/TCP) |
| 123 |
|
| 124 |
============================= |
| 125 |
|
| 126 |
Any other output from radclient or HAproxy indicates that there is a |
| 127 |
problem with the HAproxy configuration, or that FreeRADIUS is not |
| 128 |
accepting connection from the `haproxy` host, which must be solved |
| 129 |
before continuing. |
| 130 |
|
| 131 |
Once proxied connections are working we are ready to |
| 132 |
xref:protocols/proxy/enable_proxy_protocol.adoc[enable the PROXY |
| 133 |
Protocol] on both HAproxy and the RadSec server. |
| 134 |
|