The original post: /r/nginx by /u/_ginger_kid on 2024-09-26 17:57:52.
Hi. I’m in the process of migrating a very old IIS service to nginx. The service makes use of rewrite rules to serve images based on optional query parameters. Two of those parameters have an underscore in the name. Nginx will not support those for map
directives. I am trying to parse out the parameter using regex, based on various posts found on stackoverflow, but I’m not having any luck. The current map
is
map $args $format {
default $uformat;
~(^|&)logo_format=(?<temp>[^&]+) $temp;
}
where is set by another
map.
However, this just results in the entire query string value being set in the variable. I’ve tried variations, but getting the same result. Can someone help me out with the correct regex?
Worth noting - no I cannot change the requesting app to remove the underscore. There is a large install base and I cannot guarantee everyone will upgrade. I have to be able to support that base.
(admittedly I am very tired after a 20 hour work trip yesterday, so it may be obvious but I can’t see it).