Skip to content

Commit

Permalink
Add option to disable logging (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamilbk committed Feb 12, 2022
1 parent 04d95fb commit 7588884
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/docs/reference/configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Shown below is a complete listing of the configuration options available in
<!-- markdownlint-disable MD013 -->

| option | description | default value |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
| `default['firezone']['nginx']['enabled']` | Whether to enable the bundled nginx server. | `true` |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| `default['firezone']['fqdn']` | FQDN of this Firezone instance. | `(node['fqdn'] || node['hostname']).downcase` |
| `default['firezone']['config_directory']` | Top-level directory for Firezone configuration. | `'/etc/firezone'` |
| `default['firezone']['install_directory']` | Top-level directory to install Firezone to. | `'/opt/firezone'` |
Expand All @@ -25,6 +24,7 @@ Shown below is a complete listing of the configuration options available in
| `default['firezone']['admin_email']` | Email address for initial Firezone user. | `"firezone@localhost"` |
| `default['firezone']['egress_interface']` | Interface name where tunneled traffic will exit. If nil, the default route interface will be used. | `nil` |
| `default['firezone']['fips_enabled']` | Enable or disable OpenSSL FIPs mode. | `nil` |
| `default['firezone']['logging']['enabled']` | Enable or disable logging across Firezone. Set to `false` to disable logging entirely. | `true` |
| `default['enterprise']['name']` | Name used by the Chef 'enterprise' cookbook. | `'firezone'` |
| `default['firezone']['install_path']` | Install path used by Chef 'enterprise' cookbook. Should be set to the same as the `install_directory` above. | `node['firezone']['install_directory']` |
| `default['firezone']['sysvinit_id']` | An identifier used in `/etc/inittab`. Must be a unique sequence of 1-4 characters. | `'SUP'` |
Expand Down
5 changes: 5 additions & 0 deletions omnibus/cookbooks/firezone/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
# Whether to use OpenSSL FIPS mode across Firezone. Default disabled.
default['firezone']['fips_enabled'] = nil

# ## Global Logging Settings
#
# Enable or disable logging. Set this to false to disable all Firezone logs.
default['firezone']['logging']['enabled'] = true

# ## Enterprise
#
# The "enterprise" cookbook provides recipes and resources we can use for this
Expand Down
2 changes: 1 addition & 1 deletion omnibus/cookbooks/firezone/recipes/nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
owner node['firezone']['user']
group node['firezone']['group']
mode '0600'
variables(nginx: node['firezone']['nginx'])
variables(logging_enabled: node['firezone']['logging']['enabled'], nginx: node['firezone']['nginx'])
end

if node['firezone']['nginx']['enabled']
Expand Down
1 change: 1 addition & 0 deletions omnibus/cookbooks/firezone/recipes/phoenix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
group node['firezone']['group']
mode '0600'
variables(nginx: node['firezone']['nginx'],
logging_enabled: node['firezone']['logging']['enabled'],
phoenix: node['firezone']['phoenix'],
fqdn: node['firezone']['fqdn'],
fips_enabled: node['firezone']['fips_enabled'],
Expand Down
14 changes: 10 additions & 4 deletions omnibus/cookbooks/firezone/templates/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ daemon off;
worker_rlimit_nofile <%= @nginx['worker_rlimit_nofile'] %>;
<% end -%>
error_log <%= @nginx['log_dir'] %>/error.log;
<% if @logging_enabled -%>
error_log <%= @nginx['log_dir'] %>/error.log;
<% else -%>
error_log /dev/null;
<% end -%>
pid <%= @nginx['pid'] %>;

events {
Expand All @@ -32,9 +36,11 @@ http {
include <%= @nginx['dir'] %>/mime.types;
default_type application/octet-stream;

<% unless @nginx['disable_access_log'] -%>
access_log <%= @nginx['log_dir'] %>/access.log firezone;
<% end %>
<% if @logging_enabled -%>
<% unless @nginx['disable_access_log'] -%>
access_log <%= @nginx['log_dir'] %>/access.log firezone;
<% end %>
<% end -%>

server_tokens off;
add_header X-Clacks-Overhead "GNU Terry Pratchett";
Expand Down
6 changes: 4 additions & 2 deletions omnibus/cookbooks/firezone/templates/phoenix.nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ server {
}
<% end -%>
<% if @nginx['cache']['enabled'] -%>
access_log <%= @nginx['log_directory'] %>/cache.log cache;
<% if @logging_enabled -%>
<% if @nginx['cache']['enabled'] -%>
access_log <%= @nginx['log_directory'] %>/cache.log cache;
<% end -%>
<% end -%>

location ~ /sitemap\d*.xml.gz {
Expand Down
4 changes: 2 additions & 2 deletions omnibus/cookbooks/firezone/templates/sv-nginx-run.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh
exec 2>&1
<%= "export OPENSSL_FIPS=1" if node['firezone']['fips_enabled'] == true %>
<%= 'export OPENSSL_FIPS=1' if node['firezone']['fips_enabled'] == true %>

exec <%= node['runit']['chpst_bin'] %> \
-P \
<%= node['firezone']['install_directory'] %>/embedded/sbin/nginx \
-c <%= node['firezone']['nginx']['directory'] %>/nginx.conf
-c <%= node['firezone']['nginx']['directory'] %>/nginx.conf <%= '> /dev/null' unless node['firezone']['logging']['enabled'] %>
2 changes: 1 addition & 1 deletion omnibus/cookbooks/firezone/templates/sv-phoenix-run.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ exec <%= node['runit']['chpst_bin'] %> \
-P \
-U <%= node['firezone']['user'] %>:<%= node['firezone']['group'] %> \
-u <%= node['firezone']['user'] %>:<%= node['firezone']['group'] %> \
bin/firezone start
bin/firezone start <%= '> /dev/null' unless node['firezone']['logging']['enabled'] %>
2 changes: 1 addition & 1 deletion omnibus/cookbooks/firezone/templates/sv-postgresql-run.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ exec <%= node['runit']['chpst_bin'] %> \
-U <%= node['firezone']['postgresql']['username'] %> \
-u <%= node['firezone']['postgresql']['username'] %> \
<%= node['firezone']['install_directory']%>/embedded/bin/postgres \
-D <%= node['firezone']['postgresql']['data_directory'] %>
-D <%= node['firezone']['postgresql']['data_directory'] %> <%= '> /dev/null' unless node['firezone']['logging']['enabled'] %>
2 changes: 1 addition & 1 deletion omnibus/cookbooks/firezone/templates/sv-wireguard-run.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export WIREGUARD_LISTEN_PORT=<%= node['firezone']['wireguard']['port'] %>

exec <%= node['runit']['chpst_bin'] %> \
-P \
<%= node['firezone']['install_directory'] %>/embedded/bin/wireguard
<%= node['firezone']['install_directory'] %>/embedded/bin/wireguard <%= '> /dev/null' unless node['firezone']['logging']['enabled'] %>

0 comments on commit 7588884

Please sign in to comment.