0

Im working on an rails project where I need a /http-bind proxy and unable to find anything about this, or find a resource to state this is possible. I need this forward in a development environment Know its possible to use unicorn + nginx to forward the proxy with unicorn BUT im looking for a simple fast way to do it locally in my development environment.... So, is unicorn, thin, or webrick capable of doing a http-bind proxy forward?

* host.com/http-bind ( xmpp http-bind ) already running

* localhost:3000 THIN server posts to /http-bind returns a 404 not found currently nothing mapped.

Would it be possible to forward the traffic of

http://localhost:3000/http-bind 

to

my external http://host.com/http-bind ? 
Rubytastic
  • 223
  • 1
  • 2
  • 14

1 Answers1

1

Servers like thin and webrick are great for prototyping, and unicorn and passenger are great application servers, but they are not designed to be full featured web servers. For this sort of thing you really should use an actual web server (e.g. apache or nginx with passenger) as it provides enough flexibility to do these sorts of redirects and other complex configurations you'll need in production.

You can pretty easy throw nginx in front of thin; it would then answer on port 80 and proxy requests to thin on port 3000. A minimal sample config might look like:

upstream thin {
    server 127.0.0.1:3000;
}
server {
    listen   80;
    server_name .example.com;

    access_log /var/www/myapp.example.com/log/access.log;
    error_log  /var/www/myapp.example.com/log/error.log;
    root       /var/www/myapp.example.com;
    index      index.html;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_redirect    off;
        try_files $uri $uri/ @ruby;
    }

    location @ruby {
        proxy_pass http://thin;
    }
}

You could then add a location for bosh something like this:

    location /http-bind/ {
        proxy_buffering off;
        tcp_nodelay on;
        keepalive_timeout 55;
        proxy_pass http://xmpp.server:5280/xmpp-httpbind/;
    }
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • thanks, yes I have this setup in my production environment. And would rather not set this up locally also. The idea was to simply forward proxy the traffic without to much hassle. I shall modify my question its to vague – Rubytastic Sep 12 '12 at 07:19
  • If at all possible, you should set up your development environment to match production as closely as you can. Otherwise you end up having to debug things that break when you move from your development machine to staging/production since the environments are different. – Michael Hampton Sep 12 '12 at 07:25
  • agree only this involves a full xmpp stack and lots of serverside specific configuration wich im *not* willing to replicate locally. the idea is to connect to the remote XMPP server, thats the goal of this. So I can test the client code inside a prototype rails app ( wich is only a small portion to be integrated in my existing full rails application lateron ) – Rubytastic Sep 12 '12 at 07:27
  • I still think you'll have to setup nginx or something to get that far; even unicorn is an app server and not a web server. – Michael Hampton Sep 12 '12 at 07:30