add some files

This commit is contained in:
histausse 2022-06-08 22:34:50 +02:00
parent d5dba2eb59
commit 130e101cc6
Signed by: histausse
GPG key ID: 67486F107F62E9E9
5 changed files with 126 additions and 0 deletions

5
handlers/main.yml Normal file
View file

@ -0,0 +1,5 @@
---
- name: Reload nginx
systemd:
name: nginx
state: reloaded

View file

@ -8,6 +8,37 @@
retries: 3 retries: 3
until: apt_result is succeeded until: apt_result is succeeded
- name: Copy snippets
template:
src: "snippets/{{ item }}"
dest: "/etc/nginx/snippets/{{ item }}"
loop:
- connection_upgrade.conf # fix some nginx bug
- name: Ensure the cert directory exists
file:
path: /etc/nginx/certs
state: directory
- name: Create a dummy cert
block:
- name: Generate private key
openssl_privatekey:
path: /etc/nginx/certs/dummy.key
mode: u=rw,g=,o=
size: 4096
- name: Generate the signing request
openssl_csr:
path: /etc/nginx/certs/dummy.req
privatekey_path: /etc/nginx/certs/dummy.key
common_name: dummy
- name: Sign Cert
openssl_certificate:
path: /etc/nginx/certs/dummy.pem
privatekey_path: /etc/nginx/certs/dummy.key
csr_path: /etc/nginx/certs/dummy.req
provider: selfsigned
- name: Add wasm to mime type - name: Add wasm to mime type
lineinfile: lineinfile:
path: /etc/nginx/mime.types path: /etc/nginx/mime.types
@ -17,3 +48,14 @@
group: root group: root
mode: '0644' mode: '0644'
insertbefore: '}' insertbefore: '}'
- name: Copy NGINX conf
template:
src: nginx.conf
dest: /etc/nginx/nginx.conf
- name: Create the SSL reverse proxy conf
template:
src: stream_rp.conf
dest: /etc/nginx/stream_rp.conf
force: no

59
templates/nginx.conf Normal file
View file

@ -0,0 +1,59 @@
{{ ansible_managed | comment }}
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
#worker_processes auto; # <- default is 1
}
http {
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
server_tokens off;
server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip off; # compression and crypto don't mix
# include /etc/nginx/conf.d/*.conf; # Ansible
include /etc/nginx/sites-enabled/*;
}
stream {
include /etc/nginx/stream_rp.conf;
# Proxy request from the back end address
map $ssl_preread_server_name $name_from_back {
acme-v02.api.letsencrypt.org acme;
r3.o.lencr.org r3;
default self-back;
}
upstream acme {
server acme-v02.api.letsencrypt.org:443;
}
upstream r3 {
server r3.o.lencr.org:443;
}
upstream self-back {
server 127.0.0.1:9443;
}
server {
listen 192.168.10.1:443;
proxy_pass $name_from_back;
ssl_preread on;
}
}

View file

@ -0,0 +1,7 @@
{{ ansible_managed | comment }}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

13
templates/stream_rp.conf Normal file
View file

@ -0,0 +1,13 @@
{{ ansible_managed | comment }}
map $ssl_preread_server_name $name_from_front {
default self;
}
upstream self {
server 127.0.0.1:8443;
}
server {
listen 172.20.198.2:443;
proxy_pass $name_from_front;
ssl_preread on;
}