Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

nginx::site::proxy return of a 'standard' location block to redirect …

…to upstream

adds a simple way to do redirect, as before
in case it's needed, complex setups can be done with upstreams and locations
but i'm not even sure multiple upstream are needed...
  • Loading branch information...
commit 9f04beb5be496d8dc94342de3e159c6d38565333 1 parent e5b4844
@daks authored
View
5 nginx/README
@@ -107,7 +107,10 @@ nginx::site::proxy
port (optional, default: 80):
its port
- location_blocks (mandatory):
+ standard_location_block (optional):
+ use it to specify a 'standard' (see code) redirection to the upstream specified
+
+ location_blocks (optional):
an hash { $url1 => $content1, $url2 => $content2 } to define blocks like
location $url1 { $content1 }
you need to define yourself the block(s) to redirect to upstream(s)
View
1  nginx/manifests/site/proxy.pp
@@ -4,6 +4,7 @@
$port='80',
$upstreams={},
$root_dir='',
+ $standard_location_block='',
$location_blocks={},
$default_vhost=false,
$enabled=true) {
View
12 nginx/templates/proxy.erb
@@ -22,6 +22,18 @@ server {
root <%= root_dir %>;
<% end %>
+ <% if standard_location_block != '' %>
+ location / {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect off;
+ if (!-f $request_filename) {
+ proxy_pass http://<%= standard_location_block %>;
+ break;
+ }
+ }
+ <% end %>
+
<% location_blocks.each_pair do |url, content| %>
location <%= url %> {
<%= content %>
Please sign in to comment.
Something went wrong with that request. Please try again.