openreplay/scripts/dockerfiles/nginx
rjshrjndrn 40547906f7 chore(docker): reuse nginx ssl connection
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
2022-08-19 15:04:46 +02:00
..
compression.conf chore(docker): updating base image to openresty alpine 2022-08-07 12:48:25 +02:00
default.conf chore(nginx): support for env variable 2022-08-07 12:48:33 +02:00
Dockerfile chore(docker): adding curl 2022-08-19 02:45:45 +02:00
location.list chore(docker): reuse nginx ssl connection 2022-08-19 15:04:46 +02:00
nginx.conf chore(nginx): support for env variable 2022-08-07 12:48:33 +02:00
README.md chore(nginx): support for env variable 2022-08-07 12:48:33 +02:00

Nginx read urls from env

We're using openresty because of native lua support.

  1. To access the env variable using os.getenv("MY_ENV") we need to define env MY_ENV in nginx.conf

  2. use set_by_lua_block $api_endpoint { return os.getenv("MY_ENV") } in server directive of nginx.

Ref:

  1. Nginx directives: https://openresty-reference.readthedocs.io/en/latest/Directives/#set_by_lua_block
  2. env variable definition:
  3. https://github.com/openresty/lua-nginx-module#system-environment-variable-support
  4. 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