There are a number of tools that would like to provide anonymizing proxy access to a third-party resource in the same spirit as the Toolforge CDNJS and Google Fonts proxies. While helping find a resolution for T250922: MoeData causes visiting browser to load data from 3rd party sites I came up with an Ingress-only solution that would allow creating a reverse proxy attached to a path within a tool's $TOOLNAME.toolforge.org URL space. These Ingress objects use ingress-nginx specific annotations to configure nginx to act as a reverse proxy:
kind: Ingress metadata: annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/backend-protocol: https nginx.ingress.kubernetes.io/proxy-ssl-name: i.scdn.co nginx.ingress.kubernetes.io/proxy-ssl-server-name: "true" nginx.ingress.kubernetes.io/rewrite-target: /$2 nginx.ingress.kubernetes.io/upstream-vhost: i.scdn.co name: proxy-scdn namespace: tool-bd808-test spec: rules: - host: bd808-test.toolforge.org http: paths: - backend: service: name: i-scdn-co port: number: 443 path: /scdn(/|$)(.*) pathType: ImplementationSpecific
This pattern has now been used by several tools and is in danger of failing when T392356: Replace ingress-nginx before upstream EOL date is implemented.
It should be possible to create a reusable golang reverse proxy service that tools can use in combination with a custom Ingress that does not rely on ingress-nginx specific features. The proxy in https://gitlab.wikimedia.org/toolforge-repos/gitlab-content can be used as a source of inspiration and implementation for creating this new service container.
See also: