Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

environment variable injected by docker compose is not available in openresty process #247

Closed
kertL opened this issue Mar 6, 2024 · 2 comments

Comments

@kertL
Copy link

kertL commented Mar 6, 2024

I'm using openresty/openresty:1.19.3.1-8-centos7 image. There're some lines like below in the compose yml file used to start container,

environment: - SSL_IMPL=openssl_1.1.1

in nginx.conf file, I have some lua code to retrieve it,

set_by_lua_block $ssl_header{ return os.getenv("SSL_IMPL") or "unknown" }

But the retrieved value is always "unknown".

I entered the container using docker exec /bin/sh, and I can see the SSL_IMPL variable does exist in the shell.

`
admin@origin-dev:/mnt/fastmock$ docker exec fastmock_nginx_1 /bin/sh -c export | grep SSL
export SSL_IMPL="openssl_1.1.1"

`

However, the environ file under /proc for openresty process seems incomplete,

admin@origin-dev:/mnt/fastmock$ docker exec fastmock_nginx_1 cat /proc/1/environ nresty -g daemon off;

Is there any workaround to make the environment variable available?

Thanks in advance.

@neomantra
Copy link
Member

I think the issue is that you need to expose that environment variable in your nginx setup with the env directive. Without it, nginx strips environment variables for security.

@kertL
Copy link
Author

kertL commented Mar 6, 2024

It works. Thank you!

@kertL kertL closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants