File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939 Async ::HTTP ::Endpoint . parse ( "#{ scheme } ://0.0.0.0:#{ port } " ) . with ( **options )
4040 end
4141end
42+
43+ unless ENV [ "SERVICE_DIRECT_PORT" ] . to_s . empty?
44+ service "#{ hostname } -http" do
45+ include Falcon ::Environment ::Rack
46+
47+ preload "preload.rb"
48+
49+ count 1
50+
51+ protocol { Async ::HTTP ::Protocol ::HTTP11 }
52+ scheme { "http" }
53+
54+ rack_app do
55+ app = super ( )
56+ allowed_paths = %w[ /api/reporting/ /up ]
57+
58+ -> ( env ) do
59+ if allowed_paths . any? { |path | env [ "PATH_INFO" ] . start_with? ( path ) }
60+ app . call ( env )
61+ else
62+ [
63+ 403 ,
64+ { "content-type" => "text/plain" } ,
65+ [
66+ "Path #{ env [ "PATH_INFO" ] } is not allowed. Allowed paths: #{ allowed_paths . join ( ", " ) } "
67+ ]
68+ ]
69+ end
70+ end
71+ end
72+
73+ endpoint do
74+ Async ::HTTP ::Endpoint . parse (
75+ "http://0.0.0.0:#{ ENV [ "SERVICE_DIRECT_PORT" ] } "
76+ ) . with ( protocol : protocol )
77+ end
78+ end
79+ end
You can’t perform that action at this time.
0 commit comments