Rails 3 - Whitelisting list of IPs via routes

前端 未结 4 1112
半阙折子戏
半阙折子戏 2020-12-29 11:18

This is a two part question. I\'m needing to restrict a rails site that I\'m throwing on development server to only a few IP addresses, so the public can\'t access it. (Basi

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 12:02

    It is also possible to surround your route declaration with a scope like so:

    scope :constraints => lambda{|req|%w(127.0.0.1).include? req.remote_addr} do
    
      ... your beautiful routes
    
    end
    

提交回复
热议问题