puppet-nginx icon indicating copy to clipboard operation
puppet-nginx copied to clipboard

Stream module cannot be dynamically loaded

Open aleksmark opened this issue 6 years ago • 2 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.5.1
  • Ruby: ruby 2.0.0p648
  • Distribution: Amazon Linux AMI 2018.03 (RHEL 7 / CENTOS 7)
  • Module version: 0.15.0

How to reproduce (e.g Puppet code you use)

nginx::stream: true

nginx::nginx_streamhosts:
  'test-lb':
    ensure:                'present'
    listen_port:           14070
    listen_options:        'udp'
    proxy:                 'test_hosts'
    proxy_read_timeout:    '1'
    proxy_connect_timeout: '1'

nginx::nginx_upstreams:
  'test_hosts':
    context: 'stream'
    members:
      '1.2.3.4:14080':
        server: '1.2.3.4'
        port: 14080
      '1.2.3.4:14081':
        server: '1.2.3.4'
        port: 14081

What are you seeing

When I try to start/reload the nginx I got the following error

Error: /Stage[main]/Nginx::Service/Service[nginx]: Failed to call refresh: Could not restart Service[nginx]: Execution of '/sbin/service nginx restart' returned 6: nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:60
nginx: configuration file /etc/nginx/nginx.conf test failed
Error: /Stage[main]/Nginx::Service/Service[nginx]: Could not restart Service[nginx]: Execution of '/sbin/service nginx restart' returned 6: nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:60
nginx: configuration file /etc/nginx/nginx.conf test failed

What behaviour did you expect instead

Nginx to start without errors and stream module available for use

Output log

nginx -V

nginx version: nginx/1.14.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=' -Wl,-E'

error.log

2019/01/16 21:15:48 [emerg] 2177#0: unknown directive "stream" in /etc/nginx/nginx.conf:60

Any additional information you'd like to impart

The modules installed the nginx with stream configuration that is looking good.

with files

/etc/nginx/conf.stream.d/test_hosts-upstream.conf /etc/nginx/streams-available/test-lb.conf

and added this block in the main nginx.conf file

stream {
  include /etc/nginx/conf.stream.d/*.conf;
  include /etc/nginx/streams-enabled/*;
}

The ngx_stream_core_module module should be loaded dynamically (--with-stream=dynamic) but I could not find any modules (*.so) on the system.

there is no modules directory in /etc/nginx /usr/lib64/nginx/modules/ is empty

According to the documentation, should be created

https://www.nginx.com/resources/wiki/extending/converting/#compiling-a-dynamic-module

During compilation the module binary will be created as a .so file in the objs directory. This .so file is then installed into the modules sub-directory of NGINX’s installation path.

aleksmark avatar Jan 17 '19 11:01 aleksmark

I figure it out that I can install the module and the error is gone

yum install nginx-mod-stream.x86_64

Still wondering if this dependency should be installed by module and how?

aleksmark avatar Jan 17 '19 20:01 aleksmark

Still wondering if this dependency should be installed by module and how?

IMHO, yes. Maybe we can work on a general solution in issue 1247.

EmersonPrado avatar Apr 08 '23 19:04 EmersonPrado