0

Used this guide to set up Ruby on Rails on my EC2 instance. I associated an elastic ip to the instance and want to bind a test application to that ip. I did so with rails server --binding=server_public_IP but I messed something up and it doesn't work.

I've tried binding another arbitrary rails app to the ip, and it tells me that the address is not available - because it is still bound to my old one apparently. Because it was a throw-away test app, I deleted the folder but the binding still persists. How do I unbind a Rails application from my ip?

Update: I think I may have found what I need to continue here, but I still would like to know if there is a rails server --binding unbind sort of command out there.

Community
  • 1
  • 1
Csteele5
  • 1,262
  • 1
  • 18
  • 36

1 Answers1

1

The binding is for the rails process while it is running. If you stop the process, it won't be bound anymore. So there is no "unbind" command, just stop running your rails server command.

You might also double-check that you need a specific binding at all. Usually, you only need to bind is in a shared-hosting scenario. It's rarely useful outside of that. The more normal thing to do:

1) You can bind to 0.0.0.0 (i.e. all IPs). This might be useful for testing, but is probably not what you want.

2) Use the default binding (127.0.0.1/localhost only) and use a reverse proxy like Nginx, HAProxy, or even Apache (not as good).

The benefits: - You don't have to muck about with your rails config every time you relaunch your server or do EIP moves, etc. - You can run different rails apps on different ports - The reverse proxy can handle SSL/TLS traffic - the reverse proxy config will route requests to the right rails server / port.

BraveNewCurrency
  • 12,654
  • 2
  • 42
  • 50
  • So then any idea why in getting address unavailable? I have only ever gotten rails to light up on my local machines, never a cloud instance – Csteele5 Nov 01 '15 at 05:21
  • Oh, I thought it was running. It won't run because the public IP is not "yours" on your box. There is a NAT somewhere that translates to your internal private IP (which is why you can move public IPs around). The private IP is the only one you can bind to, but that's not useful. My advice: use the default binding, or in a pinch, use 0.0.0.0. – BraveNewCurrency Nov 01 '15 at 05:28