## Introduction

Ingress-nginx uses [https://github.com/openresty/lua-nginx-module](https://github.com/openresty/lua-nginx-module) to run custom Lua code within Nginx workers.

The Lua code in `custom-lua-scripts` should be placed under `/etc/nginx/lua` in the image of the ingress-nginx controller, and it will be loaded in the `nginx.conf`.

## Design

Refer to [design doc](https://pingcap.feishu.cn/wiki/TaUdwAODuiT7KBk7iSkczCA2nVf?from=from_copylink)

## Dev Guide

### Build

The Dockerfile re-use the open-source image and copy our lua scripts into `/etc/nignx/lua` folder, where all lua scripts will be loaded when nginx worker start.

### Testing

1. Copy the code under `custom-lua-scripts` and `test` to `https://github.com/kubernetes/ingress-nginx/blob/controller-v1.2.1/rootfs/etc/nginx/lua/`.
2. Run `make lua-test` to perform the unit test, it will start a docker container containing all the dependencies, and run the unit test in that container.
