vagrant-reverse-proxy 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b161ccdfa9f23fc816ef78e026e3612473a5c2d
|
4
|
+
data.tar.gz: 6e1f550ea1d7209e405937b4eefe4dacd702f344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4f5e4f857f7c261fe576c96ceab51fa8ebc28bdc76cc20a73b12c90ea6f299de4185f07edd24781b8c67daf693ad34a74a9f865269d46f0e950ea96960dc6b5
|
7
|
+
data.tar.gz: 0b4259a235e8e93e56f2d81410464686b456e51a76593b4d4662799823d77804281cdd6379486fccea05cb7bb993f7a3c86980d85c49298d32b6fda34478fd51
|
data/README.md
CHANGED
@@ -107,6 +107,36 @@ to be executed:
|
|
107
107
|
|
108
108
|
config.reverse_proxy.nginx_reload_command = 'sudo service nginx reload'
|
109
109
|
|
110
|
+
### Adding custom NGINX configuration to your proxy
|
111
|
+
|
112
|
+
Sometimes the standard settings are not enough, and you'll need
|
113
|
+
additional custom configuration in a proxy block. A good example is
|
114
|
+
when you want to support websockets; in order to do that, you need to
|
115
|
+
force NGINX to use HTTP/1.1 and pass on any `upgrade` headers to the
|
116
|
+
downstream server.
|
117
|
+
|
118
|
+
To do this, you can add a global setting that will affect all vhosts:
|
119
|
+
|
120
|
+
config.reverse_proxy.nginx_extra_config = <<EOF
|
121
|
+
proxy_http_version 1.1;
|
122
|
+
proxy_set_header Upgrade $http_upgrade;
|
123
|
+
proxy_set_header Connection "upgrade";
|
124
|
+
EOF
|
125
|
+
|
126
|
+
If you have a particular setting that applies to a single vhost only,
|
127
|
+
you can set a similar property in the vhost hash:
|
128
|
+
|
129
|
+
config.reverse_proxy.vhosts = {
|
130
|
+
"bar" => {:host => "bar.test",
|
131
|
+
:nginx_extra_config => "proxy_http_version 1.1;\nproxy_set_header Upgrade $http_upgrade;\n"}
|
132
|
+
}
|
133
|
+
|
134
|
+
These "extra configs" will be appended to the configuration, with the
|
135
|
+
vhost-specific one last. Of course, for more complicated
|
136
|
+
configuration you can just use the NGINX `include` directive to load
|
137
|
+
an extra file. **NOTE:** Remember that all NGINX config directives
|
138
|
+
require a trailing semicolon, or the config will be invalid!
|
139
|
+
|
110
140
|
## Adding proxy support to your application
|
111
141
|
|
112
142
|
This plugin will instruct NGINX to pass the following headers to your
|
@@ -136,6 +166,7 @@ add a bit of custom code there if you need to override the base URL.
|
|
136
166
|
|
137
167
|
## Changelog
|
138
168
|
|
169
|
+
- 0.5.0 Add support for `nginx_extra_config` setting (Fixes ticket #8).
|
139
170
|
- 0.4.0 Add support for `vagrant reload`, add support for host-based instead
|
140
171
|
of location-based dispatching (both thanks to Sam Stevens). NOTE: This is a
|
141
172
|
backwards incompatible change: the default name of the config file has
|
@@ -93,7 +93,7 @@ module VagrantPlugins
|
|
93
93
|
end
|
94
94
|
ip = get_ip_address(machine)
|
95
95
|
vhosts.collect do |path, vhost|
|
96
|
-
# Rewrites are
|
96
|
+
# Rewrites are matched literally by nginx, which means
|
97
97
|
# http://host:80/... will NOT match http://host/...!
|
98
98
|
port_suffix = vhost[:port] == 80 ? '' : ":#{vhost[:port]}"
|
99
99
|
<<EOF
|
@@ -108,6 +108,9 @@ location /#{path}/ {
|
|
108
108
|
|
109
109
|
proxy_pass http://#{ip}#{port_suffix}/;
|
110
110
|
proxy_redirect http://#{vhost[:host]}#{port_suffix}/ /#{path}/;
|
111
|
+
|
112
|
+
#{vhost[:nginx_extra_config]}
|
113
|
+
#{machine.config.reverse_proxy.nginx_extra_config}
|
111
114
|
}
|
112
115
|
EOF
|
113
116
|
end.join("\n")
|
@@ -122,7 +125,7 @@ EOF
|
|
122
125
|
end
|
123
126
|
ip = get_ip_address(machine)
|
124
127
|
vhosts.collect do |path, vhost|
|
125
|
-
# Rewrites are
|
128
|
+
# Rewrites are matched literally by nginx, which means
|
126
129
|
# http://host:80/... will NOT match http://host/...!
|
127
130
|
port_suffix = vhost[:port] == 80 ? '' : ":#{vhost[:port]}"
|
128
131
|
<<EOF
|
@@ -140,7 +143,11 @@ server {
|
|
140
143
|
proxy_set_header X-Forwarded-Port $server_port;
|
141
144
|
proxy_set_header X-Real-IP $remote_addr;
|
142
145
|
proxy_set_header X-Forwarded-Proto $scheme;
|
146
|
+
|
143
147
|
proxy_pass http://#{ip}#{port_suffix}/;
|
148
|
+
|
149
|
+
#{vhost[:nginx_extra_config]}
|
150
|
+
#{machine.config.reverse_proxy.nginx_extra_config}
|
144
151
|
}
|
145
152
|
}
|
146
153
|
EOF
|
@@ -2,7 +2,7 @@ module VagrantPlugins
|
|
2
2
|
module ReverseProxy
|
3
3
|
class Plugin
|
4
4
|
class Config < Vagrant.plugin(2, :config)
|
5
|
-
attr_accessor :enabled, :vhosts, :nginx_locations_config_file, :nginx_servers_config_file, :nginx_reload_command
|
5
|
+
attr_accessor :enabled, :vhosts, :nginx_locations_config_file, :nginx_servers_config_file, :nginx_reload_command, :nginx_extra_config
|
6
6
|
alias_method :enabled?, :enabled
|
7
7
|
|
8
8
|
def initialize
|
@@ -11,6 +11,7 @@ module VagrantPlugins
|
|
11
11
|
@nginx_locations_config_file = UNSET_VALUE
|
12
12
|
@nginx_servers_config_file = UNSET_VALUE
|
13
13
|
@nginx_reload_command = UNSET_VALUE
|
14
|
+
@nginx_extra_config = UNSET_VALUE
|
14
15
|
end
|
15
16
|
|
16
17
|
def finalize!
|
@@ -19,19 +20,23 @@ module VagrantPlugins
|
|
19
20
|
@vhosts = nil
|
20
21
|
elsif @vhosts.is_a?(Array)
|
21
22
|
# Convert to canonical hash form of
|
22
|
-
# {path => {:host => name, :port => num}}
|
23
|
+
# {path => {:host => name, :port => num, :nginx_extra_config => str}}
|
23
24
|
vhosts_hash = {}
|
24
|
-
@vhosts.each {|entry| vhosts_hash[entry] = {:host => entry, :port => 80} }
|
25
|
+
@vhosts.each {|entry| vhosts_hash[entry] = {:host => entry, :port => 80, :nginx_extra_config => ""} }
|
25
26
|
@vhosts = vhosts_hash
|
26
27
|
elsif @vhosts.is_a?(Hash)
|
27
28
|
@vhosts.each do |key, value|
|
28
29
|
if (value.is_a?(String))
|
29
|
-
@vhosts[key] = {:host => value, :port => 80}
|
30
|
+
@vhosts[key] = {:host => value, :port => 80, :nginx_extra_config => ""}
|
30
31
|
else
|
31
32
|
value[:port] ||= 80
|
33
|
+
value[:nginx_extra_config] ||= ""
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
37
|
+
if @nginx_extra_config == UNSET_VALUE
|
38
|
+
@nginx_extra_config = nil
|
39
|
+
end
|
35
40
|
if @nginx_locations_config_file == UNSET_VALUE
|
36
41
|
@nginx_locations_config_file = '/etc/nginx/vagrant-proxy-config-locations'
|
37
42
|
end
|
@@ -73,6 +78,10 @@ module VagrantPlugins
|
|
73
78
|
errors << 'vhosts must be an array of hostnames, a string=>string hash or nil'
|
74
79
|
end
|
75
80
|
|
81
|
+
unless @nginx_extra_config.instance_of?(String) || @nginx_extra_config == nil || @nginx_extra_config == UNSET_VALUE
|
82
|
+
errors << 'nginx_extra_config must be a string'
|
83
|
+
end
|
84
|
+
|
76
85
|
unless @nginx_locations_config_file.instance_of?(String) || @nginx_locations_config_file == nil || @nginx_locations_config_file == UNSET_VALUE
|
77
86
|
errors << 'nginx_locations_config_file must be a string'
|
78
87
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-reverse-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|