Configure VaultConfigurator direct proxy in NPM and update topology docs
This commit is contained in:
81
scripts/update_vault_direct_proxy.py
Normal file
81
scripts/update_vault_direct_proxy.py
Normal file
@@ -0,0 +1,81 @@
|
||||
import paramiko
|
||||
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect("140.44.4.71", username="root", key_filename=r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet", timeout=10)
|
||||
|
||||
nginx_conf = """# ------------------------------------------------------------
|
||||
# vault.snarfnet.net
|
||||
# ------------------------------------------------------------
|
||||
|
||||
map $scheme $hsts_header {
|
||||
https "max-age=63072000;includeSubDomains; preload";
|
||||
}
|
||||
|
||||
server {
|
||||
set $forward_scheme http;
|
||||
set $server "140.44.4.70";
|
||||
set $port 8085;
|
||||
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name vault.snarfnet.net;
|
||||
http2 off;
|
||||
|
||||
# Let's Encrypt SSL
|
||||
include conf.d/include/letsencrypt-acme-challenge.conf;
|
||||
include conf.d/include/ssl-cache.conf;
|
||||
include conf.d/include/ssl-ciphers.conf;
|
||||
ssl_certificate /etc/letsencrypt/live/npm-1/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/npm-1/privkey.pem;
|
||||
|
||||
# Asset Caching
|
||||
include conf.d/include/assets.conf;
|
||||
|
||||
# Block Exploits
|
||||
include conf.d/include/block-exploits.conf;
|
||||
|
||||
# HSTS
|
||||
add_header Strict-Transport-Security $hsts_header always;
|
||||
|
||||
# Force SSL
|
||||
set $trust_forwarded_proto "T";
|
||||
include conf.d/include/force-ssl.conf;
|
||||
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
access_log /data/logs/proxy-host-56_access.log proxy;
|
||||
error_log /data/logs/proxy-host-56_error.log warn;
|
||||
|
||||
location / {
|
||||
add_header Strict-Transport-Security $hsts_header always;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# Proxy!
|
||||
include conf.d/include/proxy.conf;
|
||||
}
|
||||
|
||||
# Custom
|
||||
include /data/nginx/custom/server_proxy[.]conf;
|
||||
}
|
||||
"""
|
||||
|
||||
cmd = f"cat << 'EOF' > /var/lib/docker/volumes/nginx-proxy-manager_nginx-data/_data/nginx/proxy_host/56.conf\n{nginx_conf}\nEOF"
|
||||
stdin, stdout, stderr = client.exec_command(cmd)
|
||||
|
||||
cmd = "python3 -c \"import sqlite3; conn=sqlite3.connect('/var/lib/docker/volumes/nginx-proxy-manager_nginx-data/_data/database.sqlite'); conn.execute('UPDATE proxy_host SET advanced_config=\"\" WHERE id=56;'); conn.commit();\""
|
||||
stdin, stdout, stderr = client.exec_command(cmd)
|
||||
|
||||
cmd = "for id in $(docker ps -q -f name=nginx-proxy-manager_app); do docker exec $id nginx -s reload; done"
|
||||
stdin, stdout, stderr = client.exec_command(cmd)
|
||||
|
||||
print("Updated 56.conf to direct proxy and reloaded")
|
||||
client.close()
|
||||
Reference in New Issue
Block a user