问题
My Rails 3.2 app connects to a number of external servers, one of which is an SQL Server database (I connect to it using ActiveRecord + tinytds).
Today, the database host decided to make it necessary to be on their VPN to access the database. My connections are now failing.
How can I connect my Rails app (or just the connection to this database) to a VPN, so that I can access this database? My app is hosted on Heroku.
回答1:
Short answer: you can't. You're going to have to switch hosts.
Longer answer: if the VPN software is available for linux, you could theoretically supply it to heroku with a custom buildpack, and then use that from your app. However, that's a pretty substantial undertaking.
EDIT: j_mcnally makes a very good point, which I forgot about. A buildpack probably will not work, because even if you do provide the software, it is unlikely that you will be able to create the tun or tap adapters needed to get it to actually work.
My final suggestion would be to host a proxy somewhere outside of the Heroku infrastructure, and bounce off that to access the database over the VPN. Maybe host it on EC2, since that way you can at least put your proxy inside the same availability zone.
回答2:
Yeah alot of VPN software for linux ends up requiring kernel extensions etc to create virtual interfaces for the vpn connections etc. So this probably will not work.
来源:https://stackoverflow.com/questions/13180305/accessing-a-database-on-a-vpn