Nginx service not up on chef server


#1

Hi All,
I am installing chef server with custom configuration in chef-server.rb.
Installation is successful but post chef-server-ctl reconfigure command, the Ngix service appears down.

[root@chefmaster var]# chef-server-ctl status
run: bookshelf: (pid 24965) 1s; run: log: (pid 20717) 3544s
down: nginx: 1s, normally up, want up; run: log: (pid 20917) 3527s
run: oc_bifrost: (pid 20426) 3577s; run: log: (pid 20466) 3577s
run: oc_id: (pid 20499) 3572s; run: log: (pid 20504) 3571s
run: opscode-erchef: (pid 20778) 3537s; run: log: (pid 20769) 3539s
run: opscode-expander: (pid 20628) 3547s; run: log: (pid 20660) 3546s
run: opscode-solr4: (pid 20570) 3551s; run: log: (pid 20601) 3550s
run: postgresql: (pid 20388) 3578s; run: log: (pid 20402) 3578s
run: rabbitmq: (pid 20313) 3580s; run: log: (pid 20305) 3580s
run: redis_lb: (pid 19959) 3662s; run: log: (pid 20900) 3530s

the reason it says

2017-06-22_02:44:14.80437 nginx: [emerg] open() "/var/log/opscode/nginx/error.log" failed (2: No such file or directory)
2017-06-22_02:44:15.84139 nginx: [emerg] open() "/var/log/opscode/nginx/error.log" failed (2: No such file or directory)

i had to create directory /var/log/opscode/nginx/ to bring service up.

the custom configuration in chef-server.rb file is

[root@chefmaster var]# grep nginx /etc/opscode/chef-server.rb
nginx['dir'] = "/data/chef/log/opscode/nginx"
nginx['log_directory'] = "/data/chef/log/opscode/nginx"
[root@chefmaster var]#

as per custome configuration it created nginx folder
[root@chefmaster var]# ls /data/chef/log/opscode/nginx
access.log config current error.log lock
[root@chefmaster var]#

looks like the nginx.conf which gets created during chef reconfigure process is copied from template nginx.conf.erb which expects /var/log/opscode/nginx/ for nginx service.

[root@chefmaster var]# grep "/var/log/opscode/nginx" /opt/opscode/embedded/cookbooks/private-chef/templates/default/nginx/nginx.conf.erb
error_log /var/log/opscode/nginx/error.log<%= node['private_chef']['lb']['debug'] ? " debug" : "" %>;
            access_log /var/log/opscode/nginx/rewrite-port-80.log;
    access_log /var/log/opscode/nginx/internal-chef.access.log opscode;
    error_log  /var/log/opscode/nginx/internal-chef.error.log<%= node['private_chef']['lb']['debug'] ? " debug" : "" %>;
    access_log /var/log/opscode/nginx/internal-authz.access.log opscode;
    error_log  /var/log/opscode/nginx/internal-authz.error.log<%= node['private_chef']['lb']['debug'] ? " debug" : "" %>;
[root@chefmaster var]#

#2

Hello!

Unfortunately, you’re spot-on in your reconstruction of what happened:

  • the logging directory of nginx is hardcoded in the template (among other places, here)

I suppose a quick work around would be to bind-mount the directory you want the logs to appear in over /var/log/opscode/nginx, and restart nginx.

Of course, the better way would be fixing the template. It would definitely make a fine contribution, if you’re so inclined :smiley:

Also, feel free to file an issue here. I’m afraid I can’t make any promises as to when this would be picked up by someone working on Chef Server, so the best way is to contribute. :wink:

Cheers
Stephan