-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for UNIX socket as alternative to host-port style of connection. #172
Comments
Can't the same security be obtained by configuring MySQL to block connections from anything but localhost? |
This is used also in the cloud to prevent external access. You usually don't have that much control in the cloud over your database instance. Its managed for you. Example use-case is a microservice or docker containers. |
Are you saying that it's common for database hosting providers to only allow access via unix socket, but not via localhost, and cannot be set up to allow connections from localhost? Do you have examples of such service providers? And if so, how do you even connect anyway to a server's unix socket if you don't already have SSH access to the machine in question? Unix-sockets are strictly machine-local. To access one, you would have to already have some kind of SSH access to the machine in question. |
The Google cloud SQL supports UNIX sockets by default. Its not a localhost issue. This a production technology for microservices. Its explained here https://cloud.google.com/sql/docs/mysql/sql-proxy |
Thanks for the link. I just took a look, but it appears the very same page makes it clear that Google Cloud SQL Proxy ALSO supports TCP just as well: "The proxy startup options you provide determine whether it will listen on a TCP port or on a Unix socket. If it is listening on a Unix socket, it creates the socket at the location you choose; usually, the /cloudsql/ directory. For TCP, the proxy listens on localhost by default." In fact, there's a table further down the page which indicates at least a couple of its features (at least on Windows anyway), even require using TCP instead of UNIX sockets. Additionally, I don't see anything on that page which suggests any preference, priority, or superiority for unix sockets as opposed to TCP. Let me try to clarify my position: I do appreciate that connecting to a DB via UNIX sockets instead of TCP is a popular, common, and certainly valid approach. And to be clear, I am absolutely in favor of mysql-native supporting UNIX sockets. I just want to be upfront that, as things stand right now, it will likely be awhile before I can get around to implementing it (though I would welcome a solid pull request at any point). This is simply because mysql-native (and other projects I work on) still have bigger priorities at the moment, and I'm only working on this in unpaid spare time. If this really is pressing, there are some things I can think of offhand which would boost the priority of a fix coming from me personally:
Short of either of those, then yes, I'll try to take care of it when I can, if nobody else contributes the feature in the meantime. In case it helps matters: If this is needed for business purposes, then as with anything else, I am open to negotiating this or any other need as paid contract work. And it doesn't have to be me, I'm sure other D developers would be open it as well. But short of that, as an unpaid volunteer effort I need to prioritize it appropriately, and so far I haven't seen any sign of this being needed, nor of it offering improved security that can't already be achieved with TCP. So far, I've only seen that sometimes people choose to use unix sockets instead of TCP, but not that they need to, and not that they reap any particular benefits they can't just as easily achieve with TCP. |
UNIX sockets provide a way to securely connect in an enclosed/isolated environment without exposing connection externally. This is used in my our microservice infrastructure on: we connect to our db instance using a proxy and its the recommended approach in microservices.
Its a very common security practice. The default approach on Google Cloud. I would do the same for any db I want to prevent external access to. If mysql-native doesn't support it then its missing a big piece of a puzzle. Database libs like mysql-native could benefit from vibe.D's implementation to support UNIX socket connection that integrates well with vibe.d.
Then the
"/tmp/vibe.sock"
will be the path to the database socket connection. An example style of this approach is in the Google Cloud SQL Nodejs demo here where they connect to the database using a proxy (UNIX socket connection) using the nodejs mysql package. Here is a snippet from the page:The text was updated successfully, but these errors were encountered: