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

Can't load .env variables into .conf #5

Open
jwise-mfg opened this issue Mar 1, 2021 · 4 comments
Open

Can't load .env variables into .conf #5

jwise-mfg opened this issue Mar 1, 2021 · 4 comments

Comments

@jwise-mfg
Copy link

This line generates the .conf from the template, but doesn't seem to load any of the sourced .env variables -- nginx -t reports them as invalid...

# Fill your config options into nginx.conf.template to create nginx.conf
envsubst \
    "$(printf '${%s} ' $(bash -c "compgen -A variable"))"\
    < "$CONFIG_DIR/nginx.conf.template" \
    > "$CONFIG_DIR/nginx.conf"
@pirate
Copy link
Owner

pirate commented Mar 1, 2021

I'd just do it by hand, there arent too many variables it actually uses in the template, and this was just a convenience suggestion I provided to autofill them (didn't test it myself).

@jwise-mfg
Copy link
Author

I am trying that, through trial and error, but an example of what it should look like would help a lot. I've successfully added a few like this at the top of the .conf file:
env PROJECT_DIR=/opt/wiki;
Where the variable value is an uninterrupted string. But variables like this throw errors:
env CACHE_REQUESTS=GET HEAD POST;
Error is:

nginx: [emerg] invalid number of arguments in "env" directive in /etc/nginx/nginx.conf:23
nginx: configuration file /etc/nginx/nginx.conf test failed

@jwise-mfg
Copy link
Author

jwise-mfg commented Mar 1, 2021

If leave out the troublesome variables, I get further validation errors like:

invalid max_size value "max_size=$CACHE_SIZE" in /etc/nginx/nginx.conf:114
nginx: configuration file /etc/nginx/nginx.conf test failed

Where my env line looks like: env CACHE_SIZE=1GB;

@pirate
Copy link
Owner

pirate commented Mar 1, 2021

I recommend following nginx docs to resolve any individual issues with nginx config keys: https://www.nginx.com/blog/nginx-caching-guide/

As mentioned in those docs, the format for that config key is max_size=10g not max_size=10GB.

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