From ffb962b108e307f150abe7be7bd5cfc9384b1ed8 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Mon, 13 Apr 2020 09:52:26 +0200 Subject: [PATCH] bundles/nginx: add nginx config --- bundles/nginx/files/nginx.conf | 35 +++++++++++++++++++++++++++++++++ bundles/nginx/files/port80.conf | 13 ++++++++++++ bundles/nginx/items.py | 23 ++++++++++++++++++++++ bundles/nginx/metadata.py | 6 +++++- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 bundles/nginx/files/nginx.conf create mode 100644 bundles/nginx/files/port80.conf create mode 100644 bundles/nginx/items.py diff --git a/bundles/nginx/files/nginx.conf b/bundles/nginx/files/nginx.conf new file mode 100644 index 0000000..5c73fdd --- /dev/null +++ b/bundles/nginx/files/nginx.conf @@ -0,0 +1,35 @@ +user www-data; +worker_processes ${worker_processes}; + +pid /var/run/nginx.pid; + + +events { + worker_connections ${worker_connections}; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + charset UTF-8; + override_charset on; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 15; + client_body_timeout 12; + client_header_timeout 12; + send_timeout 10; + + access_log off; + error_log off; + + client_body_buffer_size 10K; + client_header_buffer_size 1k; + client_max_body_size 8m; + large_client_header_buffers 2 1k; + + include /etc/nginx/sites/*; +} diff --git a/bundles/nginx/files/port80.conf b/bundles/nginx/files/port80.conf new file mode 100644 index 0000000..72299e0 --- /dev/null +++ b/bundles/nginx/files/port80.conf @@ -0,0 +1,13 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + + location / { + return 301 https://$host$request_uri; + } + + location /.well-known/acme-challenge/ { + alias /var/www/default/.well-known/acme-challenge/; + } +} diff --git a/bundles/nginx/items.py b/bundles/nginx/items.py new file mode 100644 index 0000000..754231b --- /dev/null +++ b/bundles/nginx/items.py @@ -0,0 +1,23 @@ +files = { + '/etc/nginx/nginx.conf': { + 'content_type': 'mako', + 'context': node.metadata['nginx'], + 'triggers': { + 'svc_systemd:nginx:restart', + }, + }, + '/etc/nginx/sites/000-port80.conf': { + 'source': 'port80.conf', + 'triggers': { + 'svc_systemd:nginx:restart', + }, + }, +} + +svc_systemd = { + 'nginx': { + 'needs': { + 'pkg_apt:nginx', + }, + }, +} diff --git a/bundles/nginx/metadata.py b/bundles/nginx/metadata.py index 4f05fe4..98e8a25 100644 --- a/bundles/nginx/metadata.py +++ b/bundles/nginx/metadata.py @@ -1,5 +1,5 @@ @metadata_processor -def nginx_apt_repo(metadata): +def defaults(metadata): return { 'apt': { 'repos': { @@ -19,4 +19,8 @@ def nginx_apt_repo(metadata): 'nginx': {}, }, }, + 'nginx': { + 'worker_processes': 4, + 'worker_connections': 1000, + }, }, DEFAULTS, DONE