Luckily we are still in alpha for the MySQL Proxy which allows us to change the API from time to time.
One of these changes is now merged to trunk and will end up in 0.7.0 which will be packaged soon. Kay knows more.
As talked about in my previous article we exposed more information for the address objects:
- each socket now has a
.src
and a.dst
address - each address has a human readable
.name
(previously known as.address
in the socket)
The main reason for exposing this information was a mail from a sjmudd
:
I want to route all traffic through the proxy for analyzing but still want to be able to route the traffic to several backend servers. For each backend server I would set up a virtual address on the proxy-server and have a 1:1 mapping between the dst-address of the client to the dst-address of the backend.
Our small problem (up to now) was that we only exposed the src-address of the client as proxy.connection.client.address
.
In the routing tutorial I layed out the idea a bit:
$ mysql-proxy --proxy-lua-script=./examples/tutorial-routing.lua
client src: 127.0.0.1:58502 (type = 2, address = 127.0.0.1, port = 58502
client dst: 127.0.0.1:4040 (type = 2, address = 127.0.0.1, port = 4040
server src: 127.0.0.1:58503 (type = 2, address = 127.0.0.1, port = 58503
server dst: 127.0.0.1:3306 (type = 2, address = 127.0.0.1, port = 3306
... when called with
$ mysql --host=127.0.0.1 --port=4040
If you call it with:
$ mysql --host=192.168.2.110 --port=4040
... you would get:
client src: 192.168.2.110:58553 (type = 2, address = 192.168.2.110, port = 58553
client dst: 192.168.2.110:4040 (type = 2, address = 192.168.2.110, port = 4040
server src: 127.0.0.1:58554 (type = 2, address = 127.0.0.1, port = 58554
server dst: 127.0.0.1:3306 (type = 2, address = 127.0.0.1, port = 3306
All you need now is a small map of which client-dst-ip should be routed to which proxy.global.backend
.
Comments