What is the best way to redirect 57,000 URLs on nginx?

Solution 1:

That should work fine. Note you can also use include directive for your maps so your config files would look pretty

BTW here are a couple of alternatives:

  1. You could also use proxy_cache and generate this URLs via PHP/Python/whatever else is behind nginx if it's more convenient for some reason. Note it's much slower
  2. Use exact matches, check out this thread