mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-09-24 03:37:12 +00:00
[Web] add mTLS Authentication
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
|
||||
include /etc/nginx/conf.d/includes/ssl_client_auth.conf;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=15768000;";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
@@ -101,6 +103,10 @@
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param TLS_SUCCESS $ssl_client_verify;
|
||||
fastcgi_param TLS_ISSUER $ssl_client_i_dn;
|
||||
fastcgi_param TLS_DN $ssl_client_s_dn;
|
||||
fastcgi_param TLS_CERT $ssl_client_cert;
|
||||
fastcgi_read_timeout 3600;
|
||||
fastcgi_send_timeout 3600;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
ssl_verify_client optional;
|
||||
ssl_client_certificate /etc/nginx/conf.d/client_cas.crt;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
apk add mariadb-client
|
||||
|
||||
# List client CA of all domains
|
||||
CA_LIST="/etc/nginx/conf.d/client_cas.crt"
|
||||
> "$CA_LIST"
|
||||
|
||||
# Define your SQL query
|
||||
query="SELECT DISTINCT ssl_client_ca FROM domain WHERE ssl_client_ca IS NOT NULL;"
|
||||
result=$(mysql --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "$query" -B -N)
|
||||
if [ -n "$result" ]; then
|
||||
echo "$result" | while IFS= read -r line; do
|
||||
echo -e "$line"
|
||||
done > $CA_LIST
|
||||
#tail -n 1 "$CA_LIST" | wc -c | xargs -I {} truncate "$CA_LIST" -s -{}
|
||||
echo "
|
||||
ssl_verify_client optional;
|
||||
ssl_client_certificate /etc/nginx/conf.d/client_cas.crt;
|
||||
" > /etc/nginx/conf.d/includes/ssl_client_auth.conf
|
||||
echo "SSL client CAs have been appended to $CA_LIST"
|
||||
else
|
||||
> /etc/nginx/conf.d/includes/ssl_client_auth.conf
|
||||
echo "No SSL client CAs found"
|
||||
fi
|
||||
Reference in New Issue
Block a user