How it works...
There's quite a bit going on in this recipe, so we'll go through it section by section. Firstly, the core NGINX configuration has two main sections. The first is the proxy location block directive, which is what we use to make external requests. This is because within route.lua, the location.capture function only works for internal requests. While, in this recipe, we've only made an internal request, having this proxy_pass directive allows us to easily incorporate external calls. It simply takes the remote request as part of the URI to pass through. We've also locked it down (using allow / deny) to the localhost to prevent any external misuse.
Next, we define our API location block directive. To keep the code within the main ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access