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?
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
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