vm-ansible/roles/webgateway/templates/nginx.conf

153 lines
4.7 KiB
Nginx Configuration File
Raw Normal View History

2023-03-05 23:10:44 +01:00
# {{ ansible_managed }}
2022-04-14 21:41:04 +02:00
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
2022-05-04 19:10:43 +02:00
proxy_set_header X-MS-Proxy webgateway.intra.tormakris.dev;
proxy_set_header X-MS-Forwarded-Client-IP $remote_addr;
2022-04-14 21:41:04 +02:00
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
2022-04-15 00:33:12 +02:00
proxy_set_header X-Forwarded-Proto https;
2022-05-04 19:24:25 +02:00
proxy_ssl_server_name on;
2022-04-14 21:41:04 +02:00
client_body_buffer_size 128k;
proxy_connect_timeout 90;
2022-04-14 22:46:44 +02:00
proxy_send_timeout 120;
proxy_read_timeout 300;
2022-04-16 01:02:32 +02:00
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
2022-04-14 22:46:44 +02:00
proxy_buffering off;
proxy_request_buffering off;
2022-05-28 19:07:15 +02:00
server_tokens off;
2022-04-14 21:41:04 +02:00
server {
2022-04-14 23:13:17 +02:00
listen 80 default_server;
listen [::]:80 default_server;
2022-04-14 21:41:04 +02:00
server_name _;
return 301 https://$host$request_uri;
}
{%- for proxysite in proxy -%}
2022-04-14 21:41:04 +02:00
server {
listen 443 ssl http2;
2022-04-14 22:36:27 +02:00
listen [::]:443 ssl http2;
2022-04-14 22:18:21 +02:00
server_name {{ proxysite.domain }};
2023-03-05 23:10:44 +01:00
proxy_ssl_name {{ proxysite.domain }};
2022-04-14 22:18:21 +02:00
ssl_certificate /etc/letsencrypt/live/{{ proxysite.domain }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ proxysite.domain }}/privkey.pem;
2022-05-28 19:07:15 +02:00
ssl_stapling on;
ssl_stapling_verify on;
{%- if proxysite.bigrequests %}
client_max_body_size 8G;
{%- endif %}
2022-04-14 21:41:04 +02:00
location /{
2022-04-14 22:18:21 +02:00
proxy_pass https://{{ proxysite.ip }};
2023-03-05 23:13:49 +01:00
{%- if proxysite.ignorecert %}
proxy_ssl_verify off;
{%- endif %}
2022-04-14 21:41:04 +02:00
}
2022-05-29 20:36:40 +02:00
location /metrics{
proxy_pass https://{{ proxysite.ip }};
2023-03-05 23:10:44 +01:00
allow 192.168.69.0/24;
deny all;
2022-05-29 20:36:40 +02:00
}
2022-04-14 21:41:04 +02:00
}
{%- endfor -%}
2022-04-14 21:41:04 +02:00
{%- for staticsite in static -%}
2022-04-14 21:41:04 +02:00
server {
listen 443 ssl http2;
2022-04-14 22:36:27 +02:00
listen [::]:443 ssl http2;
2022-04-14 22:18:21 +02:00
server_name {{ staticsite.domain }};
2022-04-14 22:31:45 +02:00
ssl_certificate /etc/letsencrypt/live/{{ staticsite.domain }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ staticsite.domain }}/privkey.pem;
2022-04-14 22:18:21 +02:00
root {{ staticsite.directory }};
2022-04-14 21:41:04 +02:00
location /{
try_files $uri $uri/ =404;
}
}
{%- endfor -%}
2022-04-17 14:24:18 +02:00
{%- for redirectsite in redirect -%}
2022-04-17 14:24:18 +02:00
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name {{ redirectsite.domain }};
ssl_certificate /etc/letsencrypt/live/{{ redirectsite.domain }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ redirectsite.domain }}/privkey.pem;
2022-04-17 14:48:40 +02:00
return 301 {{ redirectsite.destination }};
2022-04-17 14:24:18 +02:00
}
{%- endfor -%}
2022-05-22 23:07:20 +02:00
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name tormakristof.eu;
ssl_certificate /etc/letsencrypt/live/tormakristof.eu/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tormakristof.eu/privkey.pem;
root /var/www/tormakristof.eu;
location /{
return 301 https://www.tormakristof.eu;
}
location /.well-known{
try_files $uri $uri/ =404;
}
2022-11-23 15:17:59 +01:00
location /.well-known/webfinger {
return 301 https://mastodon.tormakristof.eu$request_uri;
}
2022-05-22 23:07:20 +02:00
}
2022-05-29 17:11:05 +02:00
server {
listen 8080;
location /stub_status {
stub_status;
allow 127.0.0.1;
deny all;
}
}
2022-04-16 18:04:52 +02:00
}