I do a lot of web development on untrusted networks (coffeeshops, the neighbors' open wifi, DEF CON), and I get twitchy when random, assuredly buggy software (my Rails app under development, say) binds a port on 0.0.0.0 and starts taking requests from all comers. I know that I can specify the address of binding with the -b option to the server, but I'd like to change the default globally so it always runs that way unless I tell it otherwise. Of course I can also run some kind of firewall which will block the connection, but better not to listen in the first place. Is there a '.railsrc' file or similar -- at least a per-project settings file, but preferably some global settings file -- which I can use to force the server to only bind to 127.0.0.1 by default?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- “Zero out” sensitive String data in Swift
- Eager-loading association count with Arel (Rails 3
- IPAddress.[Try]Parse parses 192.168 to 192.0.0.168
相关文章
- Ruby using wrong version of openssl
- Warning : HTML 1300 Navigation occured?
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
Use the
--binding=ip
parameter:https://github.com/rails/rails/blob/master/railties/lib/rails/commands/server.rb
There's no way to change it globally, you'll have to use
-b
.rails s -b <ip address>
You can update the /script/rails file in you rails app to reflect the following:
This will bind the rails app to my-host.com when it starts up. You can still override the options from the command line.
I am not sure why this is not reflected in the Rails::Server API docs. You can have a look at https://github.com/rails/rails/blob/master/railties/lib/rails/commands/server.rb to see the server implementation.
Note that in Rails 4, the /script/rails file has been moved to /bin/rails.