send nginx log to journal
Some checks failed
Test Nix flake / Test nix flake (push) Has been cancelled
Some checks failed
Test Nix flake / Test nix flake (push) Has been cancelled
This commit is contained in:
parent
14fe8e912e
commit
6022b14de8
7 changed files with 46 additions and 26 deletions
|
|
@ -1,5 +1,8 @@
|
|||
{ config, ... }:
|
||||
|
||||
let
|
||||
fqdn = "dav.${config.networking.domain}";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../../services/nginx.nix
|
||||
|
|
@ -9,15 +12,20 @@
|
|||
services = {
|
||||
baikal = {
|
||||
enable = true;
|
||||
virtualHost = "dav.${config.networking.domain}";
|
||||
virtualHost = fqdn;
|
||||
};
|
||||
|
||||
nginx.virtualHosts."dav.${config.networking.domain}" = {
|
||||
nginx.virtualHosts.${fqdn} = {
|
||||
default = true;
|
||||
quic = true;
|
||||
kTLS = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] fqdn} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@ in
|
|||
enableACME = true;
|
||||
extraConfig = ''
|
||||
merge_slashes off; # Required to handle URL-encoded slashes
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] fqdn} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
|
|
@ -93,7 +96,6 @@ in
|
|||
proxyPass = "http://unix:${config.services.forgejo.settings.server.HTTP_ADDR}";
|
||||
extraConfig = ''
|
||||
client_max_body_size 512M;
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
'';
|
||||
};
|
||||
"/metrics" = {
|
||||
|
|
@ -109,7 +111,6 @@ in
|
|||
recommendedProxySettings = true;
|
||||
proxyPass = "http://unix:${config.services.forgejo.settings.server.HTTP_ADDR}";
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
limit_req zone=forgejo_archive burst=10 nodelay;
|
||||
limit_conn forgejo_archive_conn 2;
|
||||
limit_req_status 429;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@
|
|||
kTLS = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] fqdn} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
locations = {
|
||||
"/".return = "418 \"🫖\"";
|
||||
"~ ^(/_matrix|/_synapse/client)" = {
|
||||
|
|
@ -82,7 +87,6 @@
|
|||
client_max_body_size 64M;
|
||||
proxy_set_header X-Request-ID $request_id;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
'';
|
||||
};
|
||||
"/_synapse/metrics" = {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
let
|
||||
cfg = config.services.hedgedoc.settings;
|
||||
fqdn = "md.${config.networking.domain}";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
|
|
@ -14,7 +15,7 @@ in
|
|||
enable = true;
|
||||
environmentFile = config.age.secrets.hedgedoc_db_password.path;
|
||||
settings = {
|
||||
domain = "md.${config.networking.domain}";
|
||||
domain = fqdn;
|
||||
dbURL = "postgres://hedgedoc:\${DB_PASSWORD}@sql.berlin.ccc.de:5432/hedgedoc";
|
||||
db.dialect = "postgresql";
|
||||
protocolUseSSL = true;
|
||||
|
|
@ -24,28 +25,29 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
nginx.virtualHosts."md.${config.networking.domain}" = {
|
||||
nginx.virtualHosts.${fqdn} = {
|
||||
default = true;
|
||||
quic = true;
|
||||
kTLS = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] fqdn} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://${cfg.host}:${toString cfg.port}";
|
||||
recommendedProxySettings = true;
|
||||
extraConfig = ''
|
||||
add_header Content-Security-Policy "frame-src 'self'; default-src 'self'; script-src 'self'; img-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; form-action 'self'; upgrade-insecure-requests;" always;
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
'';
|
||||
};
|
||||
"/socket.io/" = {
|
||||
proxyPass = "http://${cfg.host}:${toString cfg.port}";
|
||||
proxyWebsockets = true;
|
||||
recommendedProxySettings = true;
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
'';
|
||||
};
|
||||
"/metrics" = {
|
||||
proxyPass = "http://${cfg.host}:${toString cfg.port}";
|
||||
|
|
|
|||
|
|
@ -66,34 +66,27 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
nginx.virtualHosts."monitoring.${config.networking.domain}" = {
|
||||
nginx.virtualHosts.${fqdn} = {
|
||||
default = true;
|
||||
quic = true;
|
||||
kTLS = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
#extraConfig = ''
|
||||
# map $http_upgrade $connection_upgrade {
|
||||
# default upgrade;
|
||||
# \'\' close;
|
||||
# }
|
||||
#'';
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] fqdn} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
basicAuthFile = config.age.secrets.grafana_basic_auth.path;
|
||||
proxyPass = "http://unix:/run/grafana/grafana.sock";
|
||||
recommendedProxySettings = true;
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
'';
|
||||
};
|
||||
"/api/live/" = {
|
||||
proxyPass = "http://unix:/run/grafana/grafana.sock";
|
||||
recommendedProxySettings = true;
|
||||
proxyWebsockets = true;
|
||||
extraConfig = ''
|
||||
proxy_set_header Forwarded "$proxy_forwarded_for_element;$proxy_forwarded_by_element;host=$host;proto=$scheme";
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ in
|
|||
enableACME = true;
|
||||
extraConfig = ''
|
||||
add_header Strict-Transport-Security max-age=15768000;
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] "mta-sts.${config.networking.domain}"} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
locations."= /.well-known/mta-sts.txt" = {
|
||||
alias = "/srv/http/mta-sts.txt";
|
||||
|
|
@ -41,6 +43,8 @@ in
|
|||
extraConfig = ''
|
||||
# HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
|
||||
add_header Strict-Transport-Security max-age=15768000;
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] "www.${config.networking.domain}"} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
|
|
@ -104,6 +108,10 @@ in
|
|||
kTLS = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
extraConfig = ''
|
||||
error_log syslog:server=unix:/dev/log,tag=${builtins.replaceStrings [ "." ] [ "_" ] "staging.${config.networking.domain}"} warn;
|
||||
access_log syslog:server=unix:/dev/log vhost_combined;
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
basicAuthFile = config.age.secrets.www-staging-htpasswd.path;
|
||||
|
|
|
|||
|
|
@ -18,9 +18,13 @@
|
|||
recommendedGzipSettings = true;
|
||||
recommendedBrotliSettings = true;
|
||||
commonHttpConfig = ''
|
||||
log_format vhost_combined '$host:$server_port $remote_addr - $remote_user [$time_local] '
|
||||
'"$request" $status $body_bytes_sent '
|
||||
'"$http_referer" "$http_user_agent"';
|
||||
|
||||
map $remote_addr $proxy_forwarded_for_element {
|
||||
# IPv4 addresses can be sent as-is
|
||||
~^[0-9.]+$ "for=$remote_addr:$remote_port";
|
||||
~^[0-9.]+$ "for=\"$remote_addr:$remote_port\"";
|
||||
|
||||
# IPv6 addresses need to be bracketed and quoted
|
||||
~^[0-9A-Fa-f:.]+$ "for=\"[$remote_addr]:$remote_port\"";
|
||||
|
|
@ -30,7 +34,7 @@
|
|||
|
||||
map $server_addr $proxy_forwarded_by_element {
|
||||
# IPv4 addresses can be sent as-is
|
||||
~^[0-9.]+$ "by=$server_addr:$server_port";
|
||||
~^[0-9.]+$ "by=\"$server_addr:$server_port\"";
|
||||
|
||||
# IPv6 addresses need to be bracketed and quoted
|
||||
~^[0-9A-Fa-f:.]+$ "by=\"[$server_addr]:$server_port\"";
|
||||
|
|
|
|||
Loading…
Reference in a new issue