August 2017
Intermediate to advanced
278 pages
8h 53m
English
Our API gateway is going to be a simplified version of a production system to ensure it is easy to follow. Being OpenResty-based, it means it's easily extendible to suit your needs.
In our nginx.conf file (located in /usr/local/openresty/nginx/conf), add the following script:
location /proxy/ {
rewrite /proxy/(.*) /$1 break;
allow 127.0.0.1;
deny all;
proxy_pass $1;
}
location /api {
default_type 'application/json';
access_by_lua_file apigateway/auth.lua;
content_by_lua_file apigateway/route.lua;
}
Unlike the previous recipes, where we added the details within a lua block directive, this time we've separated the code into individual files for ease of management. Within the nginx directory (within the main OpenResty directory), ...
Read now
Unlock full access