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

Test nginx config before deploying #24

Open
wosephjeber opened this issue Jan 9, 2019 · 8 comments · May be fixed by #54
Open

Test nginx config before deploying #24

wosephjeber opened this issue Jan 9, 2019 · 8 comments · May be fixed by #54

Comments

@wosephjeber
Copy link

Is it possible to test the nginx config for errors with nginx -t before deploying? I've deployed a few bad builds of a proxy server (still in development, thankfully, so it didn't impact any production services) due to a bad config.

@beanieboi
Copy link
Member

hey,

i really like that idea, would you be able to come up with a PR to implement the changes?

ben

@beanieboi
Copy link
Member

i just had another look into this and i don't think it's possible. we need to evaluate the config.erb to get the value for the $PORT and probably other environment variables. this means we only have the full complete config during dyno boot up and not during the build phase. i'm not sure how we can evaluate a partial config.

@privettoli
Copy link

privettoli commented Jan 25, 2019

@beanieboi, maybe at least before deployment? I was trying to use gunzip (#26) and couldn't understand the reason for failing deployment.
@wosephjeber, do you think we could come up with the PR?

@jmorrell
Copy link

jmorrell commented Aug 7, 2019

Could this test be done in the start-nginx script? https://github.com/heroku/heroku-buildpack-nginx/blob/master/bin/start-nginx

@hom3chuk hom3chuk linked a pull request May 6, 2020 that will close this issue
@hom3chuk
Copy link

hom3chuk commented May 6, 2020

I'm not 100% sure on Heroku's flow and that exiting during launch script will stop build from being rolled out. But if it is like that, this PR should do the job

@beanieboi
Copy link
Member

It will not. During the build we only copy the needed files into your app (see https://github.com/heroku/heroku-buildpack-nginx/blob/master/bin/compile)

If we do this in the start-nginx script it will not prevent it from being released, your app will still crash during startup.

@jamemackson
Copy link

if there were a way to run this locally, that might allow us to catch config errors before it even hits heroku. is that at all a possibility?

@blgo
Copy link

blgo commented Sep 5, 2022

if there were a way to run this locally, that might allow us to catch config errors before it even hits heroku. is that at all a possibility?

Customise the official nginx Docker image using your own Dockerfile with your own environment variables in it:

  1. install Ruby to get "erb"
  2. override the entry point, and add the command erb /etc/nginx/nginx.conf.erb > /etc/nginx/nginx.conf
  3. Finally launch the original entrypoint sh ./docker-entrypoint.sh $*

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

Successfully merging a pull request may close this issue.

7 participants