Separate port for some URLs in Rails app

72 Views Asked by At

My Rails app listens on single port for API calls and browser requests. To increase security I would like to open another port for API and make web page URLs unabailable for this port.

How to do this in Rails? (Possibly without losing current app integrity).

I use WEBrick or Puma during development and Apache+Passenger in production.

P.S.

Currently I'm thinking about making HTTP proxy which will forward API calls.

1

There are 1 best solutions below

0
On

Unicorn will bind to all interfaces on TCP port 8080 by default. You may use the -l switch to bind to a different address:port. Each worker process can also bind to a private port via the after_fork hook. But I think it is not useful if you have nginx on top layer.