Search code examples
nginxchef-infrakerberosspnego

Dynamic loading of nginx third party module via chef


I am trying to dynamically load a third party module to nginx.

https://github.com/stnoonan/spnego-http-auth-nginx-module

Nginx is installed via package installation using chef recipe.

I have tried compiling the module to module binary .so file and copied it to /etc/nginx/modules directory and added the following line into nginx.conf, but it showed error "unknown directive load_module".

nginx.conf

load_module modules/ngx_http_auth_spnego_module.so ;

Chef recipe

bash 'create_spnego_module' do
   code <<-EOH
    mkdir -p #{node['nginx']['dir']}/modules
   EOH
 end

cookbook_file "#{node['nginx']['dir']}/modules/ngx_http_auth_spnego_module.so" do
  source 'ngx_http_auth_spnego_module.so'
  owner  'root'
  group  node['root_group']
  mode   '0644'
  notifies :reload, 'service[nginx]', :delayed
end

Is there any other way I can load this module via chef without recompiling nginx source?


Solution

  • During compilation of module binary , the configuration arguments for compiling modules should be the same as that of the installed nginx.

    Using command line argument 'nginx -V' , check the configuration arguments during nginx installation. Use the same arguments during module compilation.