-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.ru
37 lines (28 loc) · 1012 Bytes
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# This file is used by Rack-based servers to start the application.
File.expand_path("lib", __dir__).tap do |libdir|
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
end
ENV["APP_ENV"] ||= ENV["RAILS_ENV"]
use Metrics::Middleware
Bundler.require
Spectrum::Json.configure(__dir__, ENV["RAILS_RELATIVE_URL_ROOT"])
use Rack::ReverseProxy do
reverse_proxy %r{^/browse.css}, "https://#{ENV["BROWSE_HOST"]}/$1"
reverse_proxy %r{^/catalog/browse/(.*)$}, "https://#{ENV["BROWSE_HOST"]}/$1"
end
use Rack::Attack
Rack::Attack.track("haz_cookie") do |req|
req.env.has_key?("HTTP_COOKIE")
end
ENV.fetch("RACK_IP_BLOCKLIST", "").split(/\s/).each do |ip|
Rack::Attack.blocklist_ip(ip)
end
if ENV.fetch("RACK_THROTTLE", false)
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
Rack::Attack.throttle("limit requests for /spectrum/.*/record", limit: 3, period: 60) do |req|
if %r{/spectrum/.*/record/}.match?(req.path)
req.ip
end
end
end
run Spectrum::Json::App