/google-fonts-proxy-docker

Google Fonts Proxy

Primary LanguageShellEclipse Public License 2.0EPL-2.0

Google Fonts Proxy

This is a drop in replacement for Google Fonts requests so that the source IP of a calling service will not be sent to Google to avoid fines in the EU

It's an Apache HTTPd server running mod_proxy which forwards to Google and subsitutes the responses so that references to google are replaced with the request of this server.

Note this does not support URL prefixing nor SSL. So you need to route on /s and /css as needed using Traefik.

It also uses the proxy cache to reduce the requests to Google. However, it's a simple disk cache so make sure you have enough room to handle DoS attacks.

Labels

This comes in two flavors:

  1. httpd - supports X-Forwarded-* headers for automatic determination
  2. caddy - supports only STATIC_URL

Usage

service:
  fonts:
    image: trajano/google-fonts

Build test locally

docker rm -f fp ; docker build . -t f && docker run --rm --name fp -p 4000:80 -d f
curl -v 'localhost:4000/css?family=Roboto:300,400,400i,700,700i&display=swap'

Test with env var

docker rm -f fp ; docker build . -t f && docker run --rm --name fp -p 4000:80 --env STATIC_URL=http://localhost:4000/s -d f
curl -v 'localhost:4000/css?family=Roboto:300,400,400i,700,700i&display=swap'