Sql-server – How to setup an TCP/IP proxy with traffic interception, for MS SQL traffic in this case

PROXYsql serversquidtcpip

I would like to setup an MS SQL proxy server.

It should forward all requests 1:1 and make it possible to log them, and modify some of the requests or answers according to some replacement rules I setup.

Maybe some TCP IP networking software or general proxy can do this, but even better some specialised MS SQL tools.

We are still on SQL Server 2005

Best Answer

This is unlikely to work with standard networking software and regexes, since SQL Server uses binary protocol Tabular Data Stream (TDS).

You would probably need a specialized application using something like FreeTDS or jTDS to decode, modify, forward, and respond to the requests.

If security is your concern, there are several commercial products offering database firewall features. For example, Audit Vault and Database Firewall from Oracle (yes it works with SQL Server too) or Database Firewall from GreenSQL.

From an architecture perspective, if this is a brand new application being envisioned, you may want to look at not exposing the SQL server directly but handling this kind of logic at the web service layer.

EDIT: it's possible to have SQL Server use HTTP endpoints (SOAP) for specific items, but this feature is deprecated and was removed in SQL 2012, so you should not count on it as a well-supported feature. Their recommendation is to handle this at the web service layer using WCF.