From ff1f91895df54c701da778e5de16f8237a058008 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Fri, 21 Sep 2018 03:10:17 +0000 Subject: [PATCH] Add rewrite rules for HTML5 url This change makes the ProxyPass rewrites Last to stop as soon as they match. Then any requests that doesn't match a file is served the index.html. Depends-On: https://review.openstack.org/591604 Change-Id: I363c2c4d3924074c8ff5c7fd9a410e357ed71b5d --- templates/zuulv3.vhost.erb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/templates/zuulv3.vhost.erb b/templates/zuulv3.vhost.erb index f33fb56..c3d6eab 100644 --- a/templates/zuulv3.vhost.erb +++ b/templates/zuulv3.vhost.erb @@ -40,19 +40,24 @@ <% end -%> <% if scope.lookupvar('::zuul::web::tenant_name') != '' -%> - RewriteRule ^/$ /status.html [L] + RewriteRule ^/$ /status [L] # Backwards compat for old status urls. Should be removed in a few weeks. - RewriteRule ^/status$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/tenant/<%= scope.lookupvar('::zuul::web::tenant_name') %>/status [P] - RewriteRule ^/api/connection/(.*)$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/connection/$1 [P] - RewriteRule ^/api/console-stream <%= scope.lookupvar('::zuul::web::websocket_url') %>/api/tenant/<%= scope.lookupvar('::zuul::web::tenant_name') %>/console-stream [P] - RewriteRule ^/api/(.*)$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/tenant/<%= scope.lookupvar('::zuul::web::tenant_name') %>/$1 [P] + RewriteRule ^/status$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/tenant/<%= scope.lookupvar('::zuul::web::tenant_name') %>/status [P,L] + RewriteRule ^/api/connection/(.*)$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/connection/$1 [P,L] + RewriteRule ^/api/console-stream <%= scope.lookupvar('::zuul::web::websocket_url') %>/api/tenant/<%= scope.lookupvar('::zuul::web::tenant_name') %>/console-stream [P,L] + RewriteRule ^/api/(.*)$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/tenant/<%= scope.lookupvar('::zuul::web::tenant_name') %>/$1 [P,L] <% else -%> - RewriteRule ^/$ /tenants.html [L] + RewriteRule ^/$ /tenants [L] RewriteRule ^/t/(.*) /$1 [L] - RewriteRule ^/api/tenant/(.*)/console-stream <%= scope.lookupvar('::zuul::web::websocket_url') %>/api/tenant/$1/console-stream [P] - RewriteRule ^/api/(.*)$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/$1 [P] + RewriteRule ^/api/tenant/(.*)/console-stream <%= scope.lookupvar('::zuul::web::websocket_url') %>/api/tenant/$1/console-stream [P,L] + RewriteRule ^/api/(.*)$ <%= scope.lookupvar('::zuul::web::web_url') %>/api/$1 [P,L] <% end -%> + # Rewrite HTML5 route to index.html + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /index.html [L] + AddOutputFilterByType DEFLATE application/json