Bind rails server to 127.0.0.1 by default

前端 未结 4 868
长发绾君心
长发绾君心 2021-02-19 01:09

I\'d like to bind the rails server to 127.0.0.1, instead of 0.0.0.0 so its not accessible when I\'m working from coffee shops.

Is there a configuration file where I can

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 01:50

    If you are searching for Rails 5: Answer


    In Rails ~> 4.0 you can customize the boot section of the Server class:

    In /config/boot.rb add this lines:

    require 'rails/commands/server'
    
    module Rails
      class Server
        def default_options
          super.merge({Port: 10524, Host: '127.0.0.1'})
        end
      end
    end
    

    As already answered on this questions:

    How to change Rails 3 server default port in develoment?

    How to change the default binding ip of Rails 4.2 development server?

提交回复
热议问题