Nginx location blocks for three different projects
Solution 1:
Here are example configuration.
server {
listen 127.0.0.1:8088;
location / {
content_by_lua_block {
ngx.say("root")
ngx.exit(ngx.HTTP_OK)
}
}
location ~* "^\/check(.*)$" {
content_by_lua_block {
ngx.say("check")
ngx.exit(ngx.HTTP_OK)
}
}
location ~* "^\/(.*)\/+(.*)$" {
content_by_lua_block {
ngx.say("all other")
ngx.exit(ngx.HTTP_OK)
}
}
}
And here are tests:
# curl 127.0.0.1:8088
root
# curl 127.0.0.1:8088/
root
# curl 127.0.0.1:8088/ll
root
# curl 127.0.0.1:8088/ll/
all other
# curl 127.0.0.1:8088/check
check
# curl 127.0.0.1:8088/check/
check