Skip to content

Commit

Permalink
adopt a more stable proxy configuration
Browse files Browse the repository at this point in the history
adopt proxy configuration as documented by @niq (Nick Kew)

   http://www.apachetutor.org/admin/reverseproxies documents the

This pattern is more resilient to shaky redirects from the backend
This commit fixes #300.
  • Loading branch information
igalic committed Sep 5, 2013
1 parent 0b47f7c commit 8d77ebe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
18 changes: 12 additions & 6 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@
:attr => 'proxy_dest',
:value => 'http://fake.com',
:match => [
' ProxyPass / http://fake.com/',
' ProxyPassReverse / http://fake.com/',
' ProxyPass / http://fake.com/',
' <Location />',
' ProxyPassReverse /',
' </Location>',
],
:notmatch => /ProxyPass .+!$/,
},
Expand All @@ -231,10 +233,14 @@
{ 'path' => '/path-b', 'url' => 'http://fake.com/b/' },
],
:match => [
' ProxyPass /path-a http://fake.com/a/',
' ProxyPassReverse /path-a http://fake.com/a/',
' ProxyPass /path-b http://fake.com/b/',
' ProxyPassReverse /path-b http://fake.com/b/',
' ProxyPass /path-a http://fake.com/a/',
' <Location /path-a/>',
' ProxyPassReverse /',
' </Location>',
' ProxyPass /path-b http://fake.com/b/',
' <Location /path-b/>',
' ProxyPassReverse /',
' </Location>',
],
:notmatch => /ProxyPass .+!$/,
},
Expand Down
13 changes: 8 additions & 5 deletions templates/vhost/_proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
</Proxy>
<%- end -%>
<% [@proxy_pass].flatten.compact.each do |proxy| %>
ProxyPass <%= proxy['path'] %> <%= proxy['url'] %>
ProxyPassReverse <%= proxy['path'] %> <%= proxy['url'] %>
ProxyPass <%= proxy['path'] %> <%= proxy['url'] %>
<Location <%= proxy['path']%>/>
ProxyPassReverse /
</Location>
<% end %>
<% if @proxy_dest -%>
<% Array(@no_proxy_uris).each do |uri| %>
ProxyPass <%= uri %> !
<% end %>
ProxyPass / <%= @proxy_dest %>/
ProxyPassReverse / <%= @proxy_dest %>/
ProxyPreserveHost On
ProxyPass / <%= @proxy_dest %>/
<Location />
ProxyPassReverse /
</Location>
<% end -%>

2 comments on commit 8d77ebe

@hmvp
Copy link

@hmvp hmvp commented on 8d77ebe Feb 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes configurations like /jenkins -> http://localhost:8080/jenkins fail
The proxypass reverse line should be "ProxyPassReverse /<%= proxy['path']%>" or even better it should match the last part of the backend url

@igalic
Copy link
Contributor Author

@igalic igalic commented on 8d77ebe Feb 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to revert this change as discussed in #602 / #613

Please sign in to comment.