Skip to content

A proxy sidecar for moving security with MSSQL out of your services.

License

Notifications You must be signed in to change notification settings

dajudge/mssqlproxy

Repository files navigation

mssqlproxy

A proxy sidecar for moving security with MSSQL out of your services.

You connect to the proxy with any username / password combination and the proxy injects the correct login credentials.

Usage

$ docker run -p 1433:1433 -e MSSQLPROXY_PROXIES="0.0.0.0:1433=username:password@mssql-server:1433" -d dajudge/mssqlproxy:0.0.2

MSSQLPROXY_PROXIES is a comma-separated list of proxy definitions where each proxy definition looks like this:

<bindAddress>:<bindPort>=<username>:<password>@<serverHostname>:<serverPort>

Fields:

  • bindAddress: the local address to listen on
  • bindPort: the local port to listen on
  • username: the username to use for logging in to the MSSQL server
  • password: the password to use for logging into the MSQQL server
  • serverHostname: the hostname of the MSSQL server
  • serverPort: the port of the MSSQL server

Example

Start a MSSQL server instance with the password MyPassword100 (runs on port 1433):

$ docker run -e ACCEPT_EULA=y -e SA_PASSWORD=MyPassword100 --net host -d mcr.microsoft.com/mssql/server:2017-CU8-ubuntu

Start a mssqlproxy on port 51433:

$ docker run --net host -e MSSQLPROXY_PROXIES="0.0.0.0:51433=sa:MyPassword100@localhost:1433" -d dajudge/mssqlproxy:0.0.2

Talk to the MSSQL server via the proxy with invalid credentials:

$ docker run --rm --net host -it mcr.microsoft.com/mssql-tools /opt/mssql-tools/bin/sqlcmd -S tcp:localhost,51433 -U sa -P wrong
1> select @@version
2> go
                                                                                                                                                                                                                                                                                                            
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2017 (RTM-CU8) (KB4338363) - 14.0.3029.16 (X64) 
	Jun 13 2018 13:35:56 
	Copyright (C) 2017 Microsoft Corporation
	Developer Edition (64-bit) on Linux (Ubuntu 16.04.4 LTS)                                                                                                            

(1 rows affected)
1> exit

TODO

  • Improved handling of various protocol versions.
  • Strong server certificate verification (waiting for a feature in r2dbc-mssql).

About

A proxy sidecar for moving security with MSSQL out of your services.

Resources

License

Stars

Watchers

Forks

Packages

No packages published