# Using proxy to access database

**URL:** <https://www.ruby-forum.com/t/using-proxy-to-access-database/113274>\
**Category:** Rails\
**Created:** [August 29, 2007, 2:04pm UTC](https://www.ruby-forum.com/t/using-proxy-to-access-database/113274 "2007-08-29T14:04:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zemariamm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/58956e/32.png) [@zemariamm](https://www.ruby-forum.com/u/zemariamm)\
**Post date:** [August 29, 2007, 2:04pm UTC](https://www.ruby-forum.com/t/using-proxy-to-access-database/113274/1 "2007-08-29T14:04:34Z")

</div>

Hi guys,  
I’ve mais rails code on one machine and the database in the other,  
sometime ago the connection between the both was straightforward, for  
example:  
ActiveRecord::Base.establish\_connection(  
:adapter=\>“mysql”,  
:host=\>“ip.to.other.host”,  
:database=\>“databasename”,  
:username=\>“something”,  
:password=\>"\*\*\*\*\*\*\*"  
)

But now I’ve a proxy between the two machines, so to access the database  
machine i’ve to tell ActiveRecord to use the proxy, how to I tell this  
to activerecord ?

(i know, for example, to use a proxy with net/http I only 've to do  
require ‘net/http’)

```
proxy_addr = 'your.proxy.host'
proxy_port = 8080
        :
Net::HTTP::Proxy(proxy_addr, proxy_port).start('www.example.com')

```

{|http|  
# always connect to your.proxy.addr:8080  
:  
}  
Tks in advance,  
Ze Maria
