简体   繁体   中英

proxy(?) server for connecting to cloud sql instance (GCP)

I have a postgresql database on the google cloud platform (cloud SQL). I'm currently managing this database through pgadmin, installed on my laptop. I've added the IP address of my laptop to the whitelist on the cloud sql settings page. This all works.

The problem is: when I go somewhere else and I connect to a different network, the IP address changes and I cannot connect to the postgresql database (through pgadmin) from my laptop.

Is there someone who knows a (secure) solution, involving a proxy server (or something else), to connect from my laptop (and only my laptop) to my postgresql database, even if I'm not on a whitelisted network (IP address)? Maybe I can set up a VM instance and install a proxy server and use this? But I have no clue where to start (or search for).

You have many options for connecting to a Cloud SQL instance from an external applications such a Public IP address with SSL, Public IP address without SSL, Cloud SQL proxy, etc. You can see all of them here .

Between all connection options there exists Cloud SQL Proxy , it basically provides secure access to your instances without the need for Authorized networks or configuring SSL on your part.

You only need to follow the steps listed here and you will be able to connect your Cloud SQL instance using the proxy.

  1. Enable Cloud SQL Admin API on your console.

  2. Install the proxy client on your local machine (Linux):

    • wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy

    • chmod +x cloud_sql_proxy

  3. Determine how you will authenticate the proxy. You can use use a service account or let Cloud SDK take care of the authentication.

  4. However, if required by your authentication method, create a service account .

  5. Determine how you will specify your instances for the proxy. Your options for instance specification depend on your operating system and environment

  6. Start the proxy using either TCP sockets or Unix sockets.

Take note that as of this writing, Cloud SQL Proxy does not support Unix sockets on Windows.

  1. Update your application to connect to Cloud SQL using the proxy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM