Update: I've determined that it's not NGINX's fault, but I need NGINX to fix it. Details at the bottom.
I'm trying to create review apps for every branch we create. We're using NGINX as our reverse proxy, Celery for a task queue, and Flower to monitor the tasks. Flower supplies a url_prefix argument https://flower.readthedocs.io/en/latest/config.html#url-prefix.
This prefix enables deployments of Flower on non-root URLs. In other words, it allows me to deploy flower behind a reverse proxy without having to use rewrites.
Ideally, our URL scheme would look like this:
/flower/{branch_name} -> Dashboard
/flower/{branch_name}/ -> Same dashboard
/flower/{branch_name}/api/task/apply/examples.ping -> Task call
/flower/{branch_name}/api/task/apply/examples.ping/ -> Same task call
/flower/latest/ -> Latest build Dashboard
/flower/staging/ -> Staging Dashboard
/flower/v1/ -> Production Dashboard
Our current config looks like this:
location ~ /flower/([a-zA-Z0-9]+)/? {
proxy_pass http://$1_flower:5555;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
This currently works--sort of.
These currently work:
/flower/{branch_name}/
/flower/{branch_name}/api/task/apply/examples.ping
These do not:
/flower/{branch_name}
/flower/{branch_name}/api/task/apply/examples.ping/
~~I'm pretty sure the issue is how I've set up my NGINX proxy config.~~
Update: I've determined that it's not NGINX's fault, but I need NGINX to fix it.
Flower's url_prefix parameter doesn't understand that
/flower/{branch_name}/
and
/flower/{branch_name}
are the same endpoint.
I think I can solve this using a redirect from
/flower/{branch_name}
to
/flower/{branch_name}/
Does anybody know how the best practice for doing this without creating issues with the task call URLs?