From cc920ed01947572a11fff5d67e0ab3523825b7e4 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Fri, 7 Jan 2022 22:11:44 +0100 Subject: [PATCH] httpd: redirect copr /api/ URLs to fedorainfracloud.org See https://pagure.io/copr/copr/issue/1935 Prevent only /api_2, /api_3, etc from redirectring from fedoraproject.org to fedorainfracloud.org I am not entirely sure why do we need these special-cases for API but you guys are taking care of it and keeping it updated, so it must be important. If anyone can explain some context, it would be appreciated. The config is older than my involvement in the Copr project :-) Anyway, there is only one /api/ page - https://copr.fedorainfracloud.org/api and that is not an API endpoint that is programmatically accessed and that preserves backwards compatibility. It is a page that one opens in the web browser to find information about API, such as where the documentation is, and how to obtain an API token. We would like to apply the redirect from fedoraproject.org to fedorainfracloud.org even for this page. --- roles/httpd/redirect/templates/redirect.copr.conf | 2 +- .../httpd/reverseproxy/templates/reversepassproxy.coprapi.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/httpd/redirect/templates/redirect.copr.conf b/roles/httpd/redirect/templates/redirect.copr.conf index 8bf42ed1d0..6246949d28 100644 --- a/roles/httpd/redirect/templates/redirect.copr.conf +++ b/roles/httpd/redirect/templates/redirect.copr.conf @@ -1,3 +1,3 @@ RewriteEngine on -RewriteCond %{REQUEST_URI} !^/api +RewriteCond %{REQUEST_URI} !^/api_ RewriteRule ^/(.*) https://copr.fedorainfracloud.org/$1 [L,R] diff --git a/roles/httpd/reverseproxy/templates/reversepassproxy.coprapi.conf b/roles/httpd/reverseproxy/templates/reversepassproxy.coprapi.conf index f44cfd73c8..6db8057955 100644 --- a/roles/httpd/reverseproxy/templates/reversepassproxy.coprapi.conf +++ b/roles/httpd/reverseproxy/templates/reversepassproxy.coprapi.conf @@ -11,7 +11,7 @@ RequestHeader set X-Scheme https early RequestHeader set X-Forwarded-Proto https early {% endif %} -{% for path in ('api', 'api_2', 'api_3') %} +{% for path in ('api_2', 'api_3') %} ProxyPass /{{path}} https://copr.fedorainfracloud.org/{{path}} ProxyPassReverse /{{path}} https://copr.fedorainfracloud.org/{{path}} {% endfor %}