Class: Nginx::Proxy
Instance Attribute Summary
Attributes inherited from Server
#dir
Instance Method Summary
collapse
Methods inherited from Server
#access_log, #error_log, from_file, #initialize, #pid, #pidfile, #stop
Constructor Details
This class inherits a constructor from Nginx::Server
Instance Method Details
#address ⇒ Object
125
126
127
128
129
130
131
|
# File 'lib/nginx/server.rb', line 125
def address
if host
"#{host}:#{port}"
else
port
end
end
|
#locations ⇒ Object
133
134
135
136
137
138
139
140
141
|
# File 'lib/nginx/server.rb', line 133
def locations
maps.keys.map do |key|
" location /\#{key}/ {\n proxy_pass http://\#{key}/;\n }\n S\n end.join \"\\n\\n\"\nend\n"
|
#socket_of(key) ⇒ Object
111
112
113
|
# File 'lib/nginx/server.rb', line 111
def socket_of key
"#{@dir}/#{key}.sock"
end
|
#start ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/nginx/server.rb', line 97
def start
maps.each do |key, app|
fork do
server = Puma::Server.new app
server.add_unix_listener socket_of key
server.run
sleep
end
end
super
end
|
#upstreams ⇒ Object
115
116
117
118
119
120
121
122
123
|
# File 'lib/nginx/server.rb', line 115
def upstreams
maps.keys.map do |key|
" upstream \#{key} {\n server unix:\#{socket_of key};\n }\n S\n end.join \"\\n\\n\"\nend\n"
|