OpenResty and Kong: A First Look at the High-Performance Web Platform and API Gateway
When building websites and APIs today, performance and flexibility are top concerns. OpenResty is Nginx + Lua scripting — it goes beyond static proxying so you can flexibly handle all sorts of needs. Kong is an API Gateway built on OpenResty, used by many startups and large companies alike. This article is a casual walkthrough of OpenResty and Kong, plus how to debug them in containers.
What is OpenResty?
In short: OpenResty is Nginx + Lua. You can write scripts to extend functionality — API Gateway, reverse proxy, even a WAF (Web Application Firewall) — no problem.
What's so great about OpenResty?
- Super high performance: Nginx is already fast; add Lua scripts and you get flexibility plus speed.
- Easy to extend: edit a Lua script and reload — no recompilation.
- Big ecosystem: many ready-made Lua modules — auth, caching, API management, etc.
- Versatile: API Gateway, reverse proxy, WAF, log collection — all doable.
Who is it for?
- Teams wanting a high-performance API Gateway or reverse proxy
- Engineers who want to extend Nginx quickly with Lua
- Folks doing microservices and DevOps
What can you build with OpenResty?
- API Gateway
- Dynamic websites
- Reverse proxy and load balancing
- WAF (Web Application Firewall)
- Log and monitoring collection
Kong: an API Gateway built on OpenResty
Kong uses OpenResty under the hood, then modularizes API management, auth, and traffic control. Adding features means installing a plugin — super convenient.
What makes Kong special?
- Pluggable: features as plugins — add what you need.
- High performance: built on OpenResty/Nginx — speed isn't a question.
- Distributed and cloud-native: runs on K8s and Docker — very flexible.
- Active community: plenty of folks online to discuss issues with.
How does Kong relate to OpenResty?
Kong takes OpenResty's flexibility to the limit, so you don't have to write Lua to handle most API Gateway needs.
How do you debug OpenResty and Kong?
- Check the Error Log
- Usually at
/usr/local/openresty/nginx/logs/error.logor/var/log/nginx/error.log - Good for: initial debugging
- Usually at
- Enable Debug Log
- Kong: set
log_level = debuginkong.conf - OpenResty: set
error_log ... debug;innginx.conf - Good for: seeing finer execution flow
- Kong: set
- Add log calls in Lua scripts
ngx.log(ngx.ERR, "Debug info: ", cjson.encode(var))- Good for: tracing variables and flow
- API testing
- Use Postman/curl to call APIs and inspect responses
- Good for: validating plugins, routes, auth
- Plugin ordering
- Kong's plugins have order — wrong order behaves weirdly
- Official docs / community
- OpenResty: https://openresty.org/
- Kong: https://docs.konghq.com/
Remote debugging in containers (Docker)
- Get inside the container and tail logs
docker exec -it openresty-container /bin/sh tail -f /usr/local/openresty/nginx/logs/error.log - View container logs directly
docker logs -f openresty-container - Mount a local directory
docker run -v /your/local/logs:/usr/local/openresty/nginx/logs ... openresty - Capture traffic
sudo tcpdump -i docker0 port 8080 - VSCode Remote - Containers
- Edit and debug files inside the container directly from VSCode — super convenient
Common debugging tips
- Bad nginx.conf (test with
nginx -t) - Container network not connected
- Lua script bugs or missing modules
- Wrong plugin order
Closing
OpenResty supercharges Nginx, and Kong takes API Gateway to the next level. If you have API management, traffic control, or auth needs, both tools are well worth a spin. When issues come up, lean on logs and the community — debugging isn't hard!
Questions? Drop a comment — let's level up together!



























Comments