|
|
||
|---|---|---|
| .. | ||
| compression.conf | ||
| default.conf | ||
| Dockerfile | ||
| location.list | ||
| nginx.conf | ||
| README.md | ||
Nginx read urls from env
We're using openresty because of native lua support.
-
To access the env variable using
os.getenv("MY_ENV")we need to defineenv MY_ENVin nginx.conf -
use
set_by_lua_block $api_endpoint { return os.getenv("MY_ENV") }in server directive of nginx.
Ref:
- Nginx directives: https://openresty-reference.readthedocs.io/en/latest/Directives/#set_by_lua_block
- env variable definition:
- https://github.com/openresty/lua-nginx-module#system-environment-variable-support
- https://nginx.org/en/docs/ngx_core_module.html#env
Run the app
docker run -v ${PWD}/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
-v ${PWD}/location.list:/etc/nginx/conf.d/location.list --rm -it \
-e FRONTEND_ENDPOINT="http://10.0.0.55:8000" -e API_ENDPOINT="http://10.0.0.55:9000" \
-p 80:8080 -p 9145:9145 local/nginx