# How setup proxy to glue couchDB to Rails?

**URL:** <https://www.ruby-forum.com/t/how-setup-proxy-to-glue-couchdb-to-rails/186328>\
**Category:** NGINX\
**Created:** [April 5, 2010, 5:08am UTC](https://www.ruby-forum.com/t/how-setup-proxy-to-glue-couchdb-to-rails/186328 "2010-04-05T05:08:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![audreylee88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecae2f/32.png) [@audreylee88](https://www.ruby-forum.com/u/audreylee88)\
**Post date:** [April 5, 2010, 5:08am UTC](https://www.ruby-forum.com/t/how-setup-proxy-to-glue-couchdb-to-rails/186328/1 "2010-04-05T05:08:41Z")

</div>

Hello nginx people,

Is it possible to use nginx to “glue” 2 types of servers into one?

I have a rails server running here:  
[http://localhost:3000/rails/](http://localhost:3000/rails/)

And I have a couchDB server running here:  
[http://localhost:5984/](http://localhost:5984/)

I’d like to configure nginx so that it listens on 8080

I want any request directed at:  
[http://localhost:8080/rails/](http://localhost:8080/rails/)  
to be forwarded to  
[http://localhost:3000/rails/](http://localhost:3000/rails/)  
And I want all other requests to be forwarded to  
[http://localhost:5984/](http://localhost:5984/)

Have any of you done something like this?

Is nginx well suited for this or should I be learning about a true  
proxy like squid or varnish?

---

<div class="post-metadata">

**Author:** ![audreylee88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecae2f/32.png) [@audreylee88](https://www.ruby-forum.com/u/audreylee88)\
**Post date:** [April 5, 2010, 7:00am UTC](https://www.ruby-forum.com/t/how-setup-proxy-to-glue-couchdb-to-rails/186328/2 "2010-04-05T07:00:27Z")

</div>

Hi Audrey,

On 05.04.2010, at 7:07, Audrey L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d like to configure nginx so that it listens on 8080
> 
> I want any request directed at:  
> [http://localhost:8080/rails/](http://localhost:8080/rails/)  
> to be forwarded to  
> [http://localhost:3000/rails/](http://localhost:3000/rails/)  
> And I want all other requests to be forwarded to  
> [http://localhost:5984/](http://localhost:5984/)
> 
> Have any of you done something like this?  
> Yes. A lot and every day 😉

You should check this:  
[http://wiki.nginx.org/NginxHttpProxyModule](http://wiki.nginx.org/NginxHttpProxyModule)  
google: proxy\_pass site:nginx.org

> Is nginx well suited for this or should I be learning about a true  
> proxy like squid or varnish?  
> Yes nginx is a fully powered reverse proxy. IMHO the best available  
> today.

Peter.

---

<div class="post-metadata">

**Author:** ![audreylee88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecae2f/32.png) [@audreylee88](https://www.ruby-forum.com/u/audreylee88)\
**Post date:** [April 5, 2010, 7:12am UTC](https://www.ruby-forum.com/t/how-setup-proxy-to-glue-couchdb-to-rails/186328/3 "2010-04-05T07:12:45Z")

</div>

On Sun, 2010-04-04 at 20:07 -0700, Audrey L. wrote:

> Hello nginx people,
> 
> Is it possible to use nginx to “glue” 2 types of servers into one?

You mean “proxy”. Yes, Nginx is a proxy.

> to be forwarded to  
> [http://localhost:3000/rails/](http://localhost:3000/rails/)  
> And I want all other requests to be forwarded to  
> [http://localhost:5984/](http://localhost:5984/)

server {  
server\_name localhost;  
listen 8080;

location /rails {  
proxy\_pass [http://localhost:3000](http://localhost:3000);  
include proxy.conf; # other proxy settings - see docs  
}

location / {  
proxy\_pass [http://localhost:5984](http://localhost:5984);  
include proxy.conf; # other proxy settings - see docs  
}  
}

I think I’d not want to send _anything_ that isn’t under /rails to  
CouchDB, but that’s what you asked for.

> Have any of you done something like this?

Probably most anyone who’s read the documentation on proxying:

[http://wiki.nginx.org/NginxHttpProxyModule](http://wiki.nginx.org/NginxHttpProxyModule)

> Is nginx well suited for this or should I be learning about a true  
> proxy like squid or varnish?

Nginx is a true proxy. Squid and Varnish are _caching_ proxies, Nginx  
has some caching capabilities as well, although not as sophisticated  
(nor as complicated).

Regards,  
Cliff
