在企业防火墙后面使用cloud_sql_proxy - 无法连接到mysql实例

问题描述:

当我将http_proxy的https_proxy变量设置为正确的值时,我已经能够在企业防火墙后面使用Google云端sdk。它也看起来像服务帐户的初始Oauth连接与设置的代理变量一起工作。但是,当我尝试使用运行代理的计算机的mysql客户端连接时,连接到google mysql实例失败。在企业防火墙后面使用cloud_sql_proxy - 无法连接到mysql实例

这里是我的代理命令,BTW(验证代理CMD /设置工作的系统,是不是企业防火墙背后):

cloud_sql_proxy -instances=api-project-1054727403053:us-east1:mysql-google-v1=tcp:3306 -credential_file=c:\tools\myeditor.json 

2017/09/14 09:39:29 using credential file for authentication; [email protected] 
-project-1054727403053.iam.gserviceaccount.com 
2017/09/14 09:39:29 Listening on 127.0.0.1:3306 for api-project-1054727403053:us 
-east1:mysql-google-v1 
2017/09/14 09:39:29 Ready for new connections 
2017/09/14 09:39:34 New connection for "api-project-1054727403053:us-east1:mysql 
-google-v1" 
2017/09/14 09:39:57 couldn't connect to "api-project-1054727403053:us-east1:mysq 
l-google-v1": dial tcp 35.190.176.161:3307: connectex: A connection attempt fail 
ed because the connected party did not properly respond after a period of time, 
or established connection failed because connected host has failed to respond. 
2017/09/14 09:39:58 New connection for "api-project-1054727403053:us-east1:mysql 
-google-v1" 
2017/09/14 09:40:19 Throttling refreshCfg(api-project-1054727403053:us-east1:mys 
ql-google-v1): it was only called 43.386s ago 
2017/09/14 09:40:40 couldn't connect to "api-project-1054727403053:us-east1:mysq 
l-google-v1": dial tcp 35.190.176.161:3307: connectex: A connection attempt fail 
ed because the connected party did not properly respond after a period of time, 
or established connection failed because connected host has failed to respond. 
2017/09/14 09:40:41 New connection for "api-project-1054727403053:us-east1:mysql 
-google-v1" 
2017/09/14 09:41:23 couldn't connect to "api-project-1054727403053:us-east1:mysq 
l-google-v1": dial tcp 35.190.176.161:3307: connectex: A connection attempt fail 
ed because the connected party did not properly respond after a period of time, 
or established connection failed because connected host has failed to respond. 

错误看起来像 ... 拨号TCP 35.190.176.161:3307:connectex:连接尝试失败 版,因为连接的方没有正确的一段时间

后再次回应,我已经验证了上面的代理设置工作的系统,是不是在企业防火墙后面,所以我想知道是否有conf配置云代理以使用http_proxy/https_proxy建立连接并进行通信?

感谢

MySQL有它自己的协议,该协议是由HTTP完全独立的,通常在端口3306。虽然云SQL代理使用HTTP进行初始身份验证设置,实际的SQL连接包装此协议TLS端口3307不幸的是,没有办法通过HTTP代理运行MySQL协议。相反,您需要公司防火墙的例外。

如果您只需要在命令行*问Cloud SQL,我建议从Cloud Shell执行此操作,如https://cloud.google.com/sql/docs/mysql/connect-admin-ip#cloud-shell中所述。

如果您想要构建一个更复杂的应用程序,可以从防火墙后面访问Cloud SQL,那么可以构建一个GAE应用程序来公开HTTP API。然后您可以通过代理使用该API,并且GAE应用程序可以连接到Cloud SQL。