diff --git a/files/gitlab-cookbooks/gitlab-pages/libraries/gitlab_pages.rb b/files/gitlab-cookbooks/gitlab-pages/libraries/gitlab_pages.rb index e2a421ca782af7abcb5957bb275529ff35c5c988_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvbGlicmFyaWVzL2dpdGxhYl9wYWdlcy5yYg==..8e5b48ccec7b0fe768430bc21ceb74397f5e7e45_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvbGlicmFyaWVzL2dpdGxhYl9wYWdlcy5yYg== 100644 --- a/files/gitlab-cookbooks/gitlab-pages/libraries/gitlab_pages.rb +++ b/files/gitlab-cookbooks/gitlab-pages/libraries/gitlab_pages.rb @@ -157,10 +157,10 @@ { "~^(#{redirect_uri})(.*)$" => "$1$2", "~^#{url_scheme}://([^/]*)\\.(#{Gitlab['pages_nginx']['fqdn_regex']})/(.*)$" => "#{url_scheme}://$2/$1/$3", - "~^//([^/]*)\\.(#{Gitlab['pages_nginx']['fqdn_regex']})/(.*)$" => "/$1/$3", - "~^/(.*)$" => "/$namespace/$1", + "~^//([^/]*)\\.(#{Gitlab['pages_nginx']['fqdn_regex']})/(.*)$" => "#{url_scheme}://$2/$1/$3", + "~^/(.*)$" => "#{url_scheme}://#{Gitlab['pages_nginx']['fqdn_regex']}/$namespace/$1", } else { "~^(#{redirect_uri})(.*)$" => "$1$2", "~^#{url_scheme}://([^/]*)\\.(#{Gitlab['pages_nginx']['fqdn_regex']}:#{pages_port})/(.*)$" => "#{url_scheme}://$2/$1/$3", @@ -162,10 +162,10 @@ } else { "~^(#{redirect_uri})(.*)$" => "$1$2", "~^#{url_scheme}://([^/]*)\\.(#{Gitlab['pages_nginx']['fqdn_regex']}:#{pages_port})/(.*)$" => "#{url_scheme}://$2/$1/$3", - "~^//([^/]*)\\.(#{Gitlab['pages_nginx']['fqdn_regex']}:#{pages_port})/(.*)$" => "/$1/$3", - "~^/(.*)$" => "/$namespace/$1", + "~^//([^/]*)\\.(#{Gitlab['pages_nginx']['fqdn_regex']}:#{pages_port})/(.*)$" => "#{url_scheme}://$2/$1/$3", + "~^/(.*)$" => "#{url_scheme}://#{Gitlab['pages_nginx']['fqdn_regex']}:#{pages_port}/$namespace/$1", } end end diff --git a/spec/chef/cookbooks/gitlab/recipes/nginx_spec.rb b/spec/chef/cookbooks/gitlab/recipes/nginx_spec.rb index e2a421ca782af7abcb5957bb275529ff35c5c988_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9uZ2lueF9zcGVjLnJi..8e5b48ccec7b0fe768430bc21ceb74397f5e7e45_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9uZ2lueF9zcGVjLnJi 100644 --- a/spec/chef/cookbooks/gitlab/recipes/nginx_spec.rb +++ b/spec/chef/cookbooks/gitlab/recipes/nginx_spec.rb @@ -923,8 +923,8 @@ expect(content).to include('proxy_set_header X-Gitlab-Namespace-In-Path $namespace;') expect(content).to include('proxy_redirect ~^(https://projects\.pages\.localhost/auth)(.*)$ $1$2;') expect(content).to include('proxy_redirect ~^https://([^/]*)\.(pages\.localhost)/(.*)$ https://$2/$1/$3;') - expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost)/(.*)$ /$1/$3;') - expect(content).to include('proxy_redirect ~^/(.*)$ /$namespace/$1;') + expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost)/(.*)$ https://$2/$1/$3;') + expect(content).to include('proxy_redirect ~^/(.*)$ https://pages\.localhost/$namespace/$1;') expect(content).to include('proxy_hide_header X-Gitlab-Namespace-In-Path;') # Below checks are to verify proper render entries are made expect(content).to include('proxy_http_version 1.1;').twice @@ -959,8 +959,8 @@ expect(content).to include('proxy_set_header X-Gitlab-Namespace-In-Path $namespace;') expect(content).to include('proxy_redirect ~^(https://projects\.pages\.localhost/auth)(.*)$ $1$2;') expect(content).to include('proxy_redirect ~^https://([^/]*)\.(pages\.localhost:25800)/(.*)$ https://$2/$1/$3;') - expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost:25800)/(.*)$ /$1/$3;') - expect(content).to include('proxy_redirect ~^/(.*)$ /$namespace/$1;') + expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost:25800)/(.*)$ https://$2/$1/$3;') + expect(content).to include('proxy_redirect ~^/(.*)$ https://pages\.localhost:25800/$namespace/$1;') expect(content).to include('proxy_hide_header X-Gitlab-Namespace-In-Path;') # Below checks are to verify proper render entries are made expect(content).to include('proxy_http_version 1.1;').twice @@ -988,10 +988,7 @@ expect(content).not_to include('rewrite ^/([^/]+)/(.*)$ /$2 break;') expect(content).not_to include('proxy_set_header Host $1.$http_host;') expect(content).not_to include('proxy_set_header X-Gitlab-Namespace-In-Path $namespace;') - expect(content).not_to include('proxy_redirect ~^https://(projects\.pages\.localhost)/(.*)$ https://$1/$2;') - expect(content).not_to include('proxy_redirect ~^https://([^/]*)\.(pages\.localhost)/(.*)$ https://$2/$1/$3;') - expect(content).not_to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost)/(.*)$ /$1/$3;') - expect(content).not_to include('proxy_redirect ~^/(.*)$ /$namespace/$1;') + expect(content).not_to include('proxy_redirect') expect(content).to include('proxy_hide_header X-Gitlab-Namespace-In-Path;') # Below checks are to verify proper render entries are made expect(content).to include('proxy_http_version 1.1;').once @@ -1024,8 +1021,8 @@ expect(content).to include('proxy_set_header X-Gitlab-Namespace-In-Path $namespace;') expect(content).to include('proxy_redirect ~^(https://customauth\.pages\.localhost/auth)(.*)$ $1$2;') expect(content).to include('proxy_redirect ~^https://([^/]*)\.(pages\.localhost)/(.*)$ https://$2/$1/$3;') - expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost)/(.*)$ /$1/$3;') - expect(content).to include('proxy_redirect ~^/(.*)$ /$namespace/$1;') + expect(content).to include('proxy_redirect ~^//([^/]*)\.(pages\.localhost)/(.*)$ https://$2/$1/$3;') + expect(content).to include('proxy_redirect ~^/(.*)$ https://pages\.localhost/$namespace/$1;') expect(content).to include('proxy_hide_header X-Gitlab-Namespace-In-Path;') # Below checks are to verify proper render entries are made expect(content).to include('proxy_http_version 1.1;').twice