1. The problem I’m having:
Hello, I am trying to optimize a public, read-only api by heavy use of caching. All data is public so I don’t have to worry about Authorization
header or its cousins.
I am using caddy as the frontend for some time for SSL termination, certificate generation and dynamic reverse proxy (using the caddy docker plugin), but I still rely on nginx in the backend to do most of the work related to redirects and caching.
For this particular case, I needed to sort the GET query arguments so that I ensure a single cache entry for a particular request, no matter the arguments order; I did that with nginx lua. I was then able to remove an argument from the args list which might identify the client and use the curated argument list as the cache key query.
It works, but it took a while to figure out and the implementation is a bit ugly (lua to sort args, nginx map and regexes to pull out the identifier argument), which led me to wonder if there is a way in caddy to sort the arguments of a query - like caddy does, by magic , or perhaps a plugin.
I remember clearly the shock when I discovered the local_certs
option
This should be a first step in the right direction, as then I might be able to also use the caddy cache plugin for that.
Thank you so much for ideas!
2. Error messages and/or full log output:
Instead the error, I would like to change this request from the client:
https://a.host.example.com/some/route?z=1&x=2&b=bar&a=foo
into this request to the upstream server:
https://a.host.example.com/some/route?a=foo&b=bar&x=2&z=1
3. Caddy version:
2.7.5
4. How I installed and ran Caddy:
a. System environment:
docker, docker-compose
b. Command:
caddy docker-proxy --caddyfile-path /etc/caddy/Caddyfile
c. Service/unit/compose file:
N/A
d. My complete Caddy config:
N/A