I have this location block:
location /somewhere/ {
access_by_lua_file /path/to/file.lua;
add_header X-debug-message "Using location: /somewhere/" always;
...
}
and I would like to do two things:
- I would like to move the header setting line into the lua file.
- For that I have to read the location definition (matching string/regex/...) from a variable rather than typing it in as a static string ("/somewhere/").
So in the end it should just look like this with magic in the lua file (I know how to set a response header in lua).
location /somewhere/ {
access_by_lua_file /path/to/file.lua;
...
}
My problem: I have no clue...
- ...if there is a variable storing the location desciption ("/somewhere/") - and not the requested URI/URL/PATH and
- if so - where that variable can be found.
So how do I access this information from within lua code?
Example
Called URL: https://mydomain.nowhere/somewhere/servicex/1234
Location that matches: "location /somewhere/ { ..."
String I want to get: "/somewhere/" (so exactly the definition of the location block).