Compare commits

..

2 commits

Author SHA1 Message Date
30f6f1f3ee
Move nftables to its own playbook. 2024-03-02 12:03:14 +01:00
0a67d1ba01
Update reverse proxy. 2024-03-02 11:57:21 +01:00
6 changed files with 25 additions and 19 deletions

View file

@ -0,0 +1,5 @@
- name: Include variables files & load nftables.conf
hosts: localhost
roles:
- include-vars
- nftables

View file

@ -1,8 +1,7 @@
- name: Include variables files & load nftables.conf - name: Include variables files
hosts: localhost hosts: localhost
roles: roles:
- include-vars - include-vars
- nftables
- name: Update project(s) - name: Update project(s)
hosts: localhost hosts: localhost

View file

@ -0,0 +1,3 @@
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# add_header X-Robots-Tag "noindex, nofollow" always;
add_header Set-Cookie "Path=/; HttpOnly; Secure";

View file

@ -22,6 +22,15 @@
group: root group: root
mode: '644' mode: '644'
register: nginx_template_reverse_proxy_conf_result register: nginx_template_reverse_proxy_conf_result
- name: Copy ssl-headers.conf to /etc/nginx/conf.d/ssl-headers.conf
copy:
src: files/ssl-headers.conf
dest: /etc/nginx/conf.d/ssl-headers.conf
owner: root
group: root
mode: '644'
register: nginx_copy_ssl_headers_conf_result
- name: Remove all enabled NGINX sites - name: Remove all enabled NGINX sites
file: file:
@ -66,5 +75,5 @@
service: service:
name: nginx name: nginx
# Reload if conf changed, if not make sure it is started # Reload if conf changed, if not make sure it is started
state: "{{ (nginx_template_nginx_conf_result['changed'] or nginx_template_reverse_proxy_conf_result['changed']) | ternary('reloaded', 'started') }}" state: "{{ (nginx_template_nginx_conf_result['changed'] or nginx_template_reverse_proxy_conf_result['changed'] or nginx_copy_ssl_headers_conf_result['changed']) | ternary('reloaded', 'started') }}"
enabled: yes enabled: yes

View file

@ -19,15 +19,10 @@ http {
tcp_nodelay on; tcp_nodelay on;
gzip off; gzip off;
types_hash_max_size 2048;
server_tokens off; server_tokens off;
keepalive_timeout 30; keepalive_timeout 30;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types; include /etc/nginx/mime.types;
default_type application/octet-stream;
## ##
# SSL Settings # SSL Settings
@ -64,10 +59,6 @@ http {
resolver {{ reverse_proxy['resolver'] }}; resolver {{ reverse_proxy['resolver'] }};
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# add_header X-Robots-Tag "noindex, nofollow" always;
add_header Set-Cookie "Path=/; HttpOnly; Secure";
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Port $server_port;

View file

@ -30,12 +30,16 @@ server {
location = /.well-known/matrix/server { location = /.well-known/matrix/server {
default_type application/json; default_type application/json;
return 200 '{ "m.server": "matrix.{{ domain }}:443" }'; return 200 '{ "m.server": "matrix.{{ domain }}:443" }';
} }
location = /.well-known/matrix/client { location = /.well-known/matrix/client {
default_type application/json; default_type application/json;
include /etc/nginx/conf.d/ssl-headers.conf;
add_header Access-Control-Allow-Origin '*'; add_header Access-Control-Allow-Origin '*';
return 200 '{ "m.homeserver": { "base_url": "https://matrix.{{ domain }}" } }'; return 200 '{ "m.homeserver": { "base_url": "https://matrix.{{ domain }}" } }';
} }
@ -67,13 +71,11 @@ server {
location / { location / {
proxy_pass http://127.0.0.1:{{ ports['element'] }}; proxy_pass http://127.0.0.1:{{ ports['element'] }};
include /etc/nginx/conf.d/ssl-headers.conf;
add_header X-Frame-Options SAMEORIGIN; add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block"; add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "frame-ancestors 'none'"; add_header Content-Security-Policy "frame-ancestors 'none'";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header Set-Cookie "Path=/; HttpOnly; Secure";
} }
} }
@ -121,8 +123,7 @@ server {
location / { location / {
proxy_pass http://127.0.0.1:{{ ports['searxng'] }}; proxy_pass http://127.0.0.1:{{ ports['searxng'] }};
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; include /etc/nginx/conf.d/ssl-headers.conf;
add_header Set-Cookie "Path=/; HttpOnly; Secure";
add_header Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self' https://github.com/searxng/searxng/issues/new; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self' https://overpass-api.de; img-src 'self' data: https://*.tile.openstreetmap.org; frame-src https://www.youtube-nocookie.com https://player.vimeo.com https://www.dailymotion.com https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com"; add_header Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self' https://github.com/searxng/searxng/issues/new; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self' https://overpass-api.de; img-src 'self' data: https://*.tile.openstreetmap.org; frame-src https://www.youtube-nocookie.com https://player.vimeo.com https://www.dailymotion.com https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com";
} }
} }
@ -188,7 +189,5 @@ server {
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade; proxy_set_header Connection $connection_upgrade;
client_max_body_size 525M;
} }
} }