voxpupuli / puppet-nginx

Puppet Module to manage NGINX on various UNIXes
https://forge.puppet.com/puppet/nginx
MIT License
471 stars 882 forks source link

custom stream_log not properly defined #1551

Open 3rwan opened 1 year ago

3rwan commented 1 year ago

Affected Puppet, Ruby, OS and module versions/distributions

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

Hiera code declaration for our custom nginx configuration

custom_nginx::config:
  stream: true
  map_hash_bucket_size: 128
  log_format:
    combined_lb: '[$time_local] TO:$http_host:$server_port FROM:$remote_addr:$remote_port BALANCED_TO:$upstream_addr REQ:"$request" $status upstream_resp_time:$upstream_response_time "$http_referer" "$http_user_agent" $remote_user'
    combined_lb_ssl: '[$time_local] TO:$http_host:$server_port FROM:$remote_addr:$remote_port WITH:$ssl_protocol/$ssl_cipher BALANCED_TO:$upstream_addr REQ:"$request" $status upstream_resp_time:$upstream_response_time "$http_referer" "$http_user_agent" $remote_user'
  stream_log_format:
    stream_combined_lb: '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr" "$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"'

the code used on our custom puppet module

  class { 'nginx':
    manage_repo            => $manage_repo,
    package_source         => $package_source,
    package_name           => $package_name,
    package_ensure         => $package_ensure,
    service_name           => $service_name,
    server_purge           => $server_purge,
    confd_purge            => $confd_purge,
    log_format             => $log_format,
    stream_log_format      => $stream_log_format,
    server_tokens          => 'off',
    worker_connections     => $worker_connections,
    worker_rlimit_nofile   => $worker_rlimit_nofile,
    http_raw_prepend       => $http_raw_prepend,
    names_hash_bucket_size => $map_hash_bucket_size,
    stream                 => $stream,
  }

What are you seeing

on the configuration file for nginx

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

  log_format stream_combined_lb '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr" "$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

  access_log /var/log/nginx/stream-access.log;
}

What behaviour did you expect instead

on the configuration file for nginx

stream {

  log_format stream_combined_lb '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr" "$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

  access_log off;

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

Output log

when testing the nginx configuration file

sandbox-lb1-dev-rbx ~ # nginx -t
nginx: [emerg] unknown log format "stream_combined_lb" in /etc/nginx/streams-enabled/my_stream_config_file:5
nginx: configuration file /etc/nginx/nginx.conf test failed
sandbox-lb1-dev-rbx ~ #
3rwan commented 1 year ago

up