cloudfoundry / nginx-buildpack

Cloud Foundry buildpack that provides NGINX
Apache License 2.0
30 stars 66 forks source link

{{nameservers}} not working in nginx.conf #24

Closed kodemus closed 4 years ago

kodemus commented 4 years ago

nginx_buildpack_v1_1_3

I want to push an application with the nameserver injected by cf as described here : {{nameservers}} - support for CF internal domain resolver

My code in nginx.conf is :

http {
  resolver {{nameservers}};
}

I expect the dns servers to be extracted from /etc/resolv.conf and injected in the nginx.conf file. It would then become :

http {
  resolver 169.254.0.2;
}

The application is not pushed and the following error occurs :

   -----> Supplying nginx
   -----> Requested nginx version: mainline => 1.17.7
   -----> Installing nginx 1.17.7
          Copy [/tmp/buildpacks/1773a27b0739b86b0235a214427fbd94/dependencies/502c9539995224def16e6d4673147ac1/nginx-1.17.7-linux-x64-cflinuxfs3-718363fe.tgz]
          **ERROR** Could not write tmp config file: template: conf:35:13: executing "conf" at <nameservers>: wrong number of args for nameservers: want 1 got 0
          **ERROR** Could not validate nginx.conf: template: conf:35:13: executing "conf" at <nameservers>: wrong number of args for nameservers: want 1 got 0
   Failed to compile droplet: Failed to run all supply scripts: exit status 14
   Exit status 223

As far as I understand, the issue comes from the file src/nginx/supply/supply.go, line 266 :

"nameservers": func(arg string) string

instead of

"nameservers": func() string

as specified in file src/nginx/varify/varify.go, line 92 :

"nameservers": func() string

Please confirm where necessary:

cf-gitbot commented 4 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/170595121

The labels on this github issue will be updated when the story is started.

kinjelom commented 4 years ago

@kodemus You're right, it was a bug. Please test it with the fixed buildpack:

cf push theapp -b https://github.com/i6e/nginx-buildpack.git
cf ssh theapp -c "cat app/nginx.conf | grep resolver"

I'll do PR.

ryanmoran commented 4 years ago

I'm going to close this since the PR was resolved. Thanks!