-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.ru
51 lines (41 loc) · 1.32 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
require 'dotenv/load'
# Last Gasp Effort to catch the error
require 'ditty/middleware/error_catchall'
use ::Ditty::Middleware::ErrorCatchall if ENV['APP_ENV'] == 'production'
use Rack::Static, root: 'public', urls: ['/favicon.ico', '/css', '/images', '/js'], header_rules: [
[:all, { 'Cache-Control' => 'public, max-age=31536000' }]
]
# Session
use Rack::Session::Cookie,
key: '_ProxES_session',
path: '/',
# :secure=>!TEST_MODE, # Uncomment if only allowing https:// access
secret: File.read('.session_secret')
require './application'
require 'ditty/services/authentication'
use OmniAuth::Builder do
Ditty::Services::Authentication.config.each do |prov, config|
provider prov, *config[:arguments]
end
end
map '/_proxes' do
require 'ditty/middleware/accept_extension'
require 'rack/content_type'
use Ditty::Middleware::AcceptExtension
use Rack::ContentType
run Rack::URLMap.new Ditty::Components.routes
end
map '/' do
# Proxy all Elasticsearch requests
require 'ditty/services/logger'
require 'proxes/forwarder'
require 'proxes/middleware/error_handling'
require 'proxes/middleware/metrics'
# Security
use ProxES::Middleware::Metrics
use ProxES::Middleware::ErrorHandling
use Rack::ContentLength
# Forward requests to ES
run ProxES::Forwarder.instance
end