+1 to this version of it, with the removal of the /'s in the regex which
I think Apache would take literally.
If we want to be pedantic, then escape the .'s in the regex with a \,
but in this case it doesn't matter much.
-re
On 2019-10-15 14:19, kevin(a)scrye.com wrote:
> From: Kevin Fenzi <kevin(a)scrye.com>
>
> This version is just two lines. Adding a host alias to registry so it uses the same
> vhost there, and then checking for the hostname in the rewrite.
>
> Signed-off-by: Kevin Fenzi <kevin(a)scrye.com>
> ---
> playbooks/include/proxies-websites.yml | 2 +-
> .../httpd/reverseproxy/templates/reversepassproxy.registry-generic.conf | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/playbooks/include/proxies-websites.yml
b/playbooks/include/proxies-websites.yml
> index 8dd1740..c87677f 100644
> --- a/playbooks/include/proxies-websites.yml
> +++ b/playbooks/include/proxies-websites.yml
> @@ -666,7 +666,7 @@
>
> - role: httpd/website
> site_name:
registry.fedoraproject.org
> - server_aliases: [
registry.stg.fedoraproject.org]
> + server_aliases: [
registry.stg.fedoraproject.org
registry-no-cdn.fedoraproject.org]
> sslonly: true
> cert_name: "{{wildcard_cert_name}}"
>
> diff --git
a/roles/httpd/reverseproxy/templates/reversepassproxy.registry-generic.conf
b/roles/httpd/reverseproxy/templates/reversepassproxy.registry-generic.conf
> index 8a97f39..9bc9eba 100644
> --- a/roles/httpd/reverseproxy/templates/reversepassproxy.registry-generic.conf
> +++ b/roles/httpd/reverseproxy/templates/reversepassproxy.registry-generic.conf
> @@ -6,6 +6,7 @@ ProxyPreserveHost On
>
> {% if env == "production" %}
> RewriteCond %{HTTP:VIA} !cdn77
> +RewriteCond %{SERVER_NAME} !/^registry-no-cdn.fedoraproject.org$/
> RewriteCond %{REQUEST_METHOD} !^(PATCH|POST|PUT|DELETE|HEAD)$
> RewriteRule ^/v2/(.*)/blobs/([a-zA-Z0-9:]*)
https://cdn.registry.fedoraproject.org/v2/$1/blobs/$2 [R]
> {% endif %}
>