Maps and lookups
4 answers
Lookup tables, blocklists and values you use elsewhere.
Looking for something specific
The searchable index covers all 326 answers at once and filters as you type.
112 Make a lookup table
- Maps, Add one.
- Choose what it reads, such as the browser type or the requested host.
- Name the variable it sets. You invent this name and then use it elsewhere.
- Add the rules, most specific first. The first match wins.
- Say what to use when nothing matches.
A plain word matches exactly. A squiggle in front makes it a pattern, and a squiggle and a star makes the pattern ignore capital letters.
113 Build a blocklist I can update from a script
Make a map keyed on the client address, set a variable, and use it on the sites you want protected. Then push updates through the JSON API rather than editing by hand.
Each update means a config render and a graceful reload, so this suits a list you change a few times an hour rather than thousands of times a minute.
114 Why does my map value get refused?
The variable a map sets is checked before it is saved. A name nginx does not recognize would stop nginx starting on every server at once, so it is refused at the point of typing instead.
204 Use one lookup table across several sites
That is what maps are for. Make it once under Maps, and every site can read the variable it sets. A blocklist, a redirect table, a country to language table, all in one place.
The alternative is the same list pasted into six sites, five of which are out of date by Christmas.
These are hostnames on the map dialog matters if the values are domain names, because it makes the matching work the way names work, with the wildcard on the left.