Rails CLI server bind host defaults to 127.0.0.1, is there a way to make it default to 0.0.0.0?

I’m trying to make the rails CLI server bind host default to 0.0.0.0 on
some machines i manage. Currently, it binds to localhost/127.0.0.1, and
it
seems to keep catching new developers who are unaware of this.

Currently, i’m wrapping the rails command with a shell script,
automatically injecting the -b 0.0.0.0 flag if it is not provided.
This
is rather hacky though, and gems has issues with it (it won’t uninstall
rails apparently, but that’s besides the point).

Do you have any recommendations for defaulting to 0.0.0.0?

Any thoughts would be appreciated. Thanks,

On Fri, Apr 10, 2015 at 5:06 AM, Lee O. [email protected]
wrote:

I’m trying to make the rails CLI server bind host default to 0.0.0.0 on some
machines i manage. Currently, it binds to localhost/127.0.0.1, and it seems
to keep catching new developers who are unaware of this.

that is fine. they are new developers and the default localhost is
safe for them : )

Currently, i’m wrapping the rails command with a shell script, automatically
injecting the -b 0.0.0.0 flag if it is not provided. This is rather hacky
though, and gems has issues with it (it won’t uninstall rails apparently,
but that’s besides the point).

Do you have any recommendations for defaulting to 0.0.0.0?

you can override Rails::Server#default_options and merge this hash
{Host: “0.0.0.0”, Port:3000}

changing defaults is not my habit so i wont recommend it.
i would prefer instead creating a new rake task that start rails w the
default options i want

kind regards
–botp

that is fine. they are new developers and the default localhost is
safe for them : )

Generally i agree, but it’s not really up for me to change. And
regarding
localhost being safe, it’s actually (mostly) useless. The machines in
question are not the localhost (though, on the network) - so localhost
is
nearly useless for them heh. One way or another, i need to do it
unfortunately… and my solution of wrapping the rails bin seems pretty
bad,
heh

you can override Rails::Server#default_options and merge this hash
{Host: “0.0.0.0”, Port:3000}

To be clear, you’re saying modify the command rails puts in the bin? Eg,
/usr/local/bin/rails?

changing defaults is not my habit so i wont recommend it.
i would prefer instead creating a new rake task that start rails w the
default options i want

I would agree there, but i’m trying to implement a default option for
the
global rails command. You’re referring to a project-local rake task,
correct?

Note: Pardon any ignorant statements about rails/ruby, i’m not a ruby
person. This is more of a general unix task, that i am hoping actual
rails
developers might have a better solution for :slight_smile:

I appreciate your reply!

On Mon, Apr 13, 2015 at 10:54 AM, Lee O. [email protected]
wrote:

Generally i agree, but it’s not really up for me to change. And regarding
localhost being safe, it’s actually (mostly) useless. The machines in
question are not the localhost (though, on the network)

So your developers are “working on” remote machines? Unusual.

In any case, you can specify alternate port, binding, etc. options in
the config.ru file.

HTH,

Hassan S. ------------------------ [email protected]

twitter: @hassan
Consulting Availability : Silicon Valley or remote

On Wed, Apr 15, 2015 at 10:34 PM, Brian S.
[email protected] wrote:

In any case, you can specify alternate port, binding, etc. options in
the config.ru file.

Is this documented somewhere? Officially or just unofficialy?

(tutorial) rackup howto · rack/rack Wiki · GitHub

That’s the only place I’ve seen it mentioned.


Hassan S. ------------------------ [email protected]

twitter: @hassan
Consulting Availability : Silicon Valley or remote

On Mon, 13 Apr 2015 12:54:42 -0700
Hassan S. [email protected] wrote:

On Mon, Apr 13, 2015 at 10:54 AM, Lee O. [email protected] wrote:

Generally i agree, but it’s not really up for me to change. And regarding
localhost being safe, it’s actually (mostly) useless. The machines in
question are not the localhost (though, on the network)

So your developers are “working on” remote machines? Unusual.

In any case, you can specify alternate port, binding, etc. options in
the config.ru file.

Is this documented somewhere? Officially or just unofficialy?