52 lines
1.7 KiB
Bash
Executable File
52 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
echo "=== 1. Бэкап текущего файла ==="
|
|
ssh root@193.233.210.184 'cp /etc/nginx/sites-available/vault.buryans.ru /root/vault.buryans.ru.bak-$(date +%H%M%S)'
|
|
|
|
echo ""
|
|
echo "=== 2. Перезаписываем файл правильно ==="
|
|
ssh root@193.233.210.184 'cat > /etc/nginx/sites-available/vault.buryans.ru << '"'"'NGINX'"'"'
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name vault.buryans.ru;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
http2 on;
|
|
server_name vault.buryans.ru;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/vault.buryans.ru/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/vault.buryans.ru/privkey.pem;
|
|
|
|
location / {
|
|
proxy_pass http://192.168.1.109:8001;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host vault.buryans.ru;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host vault.buryans.ru;
|
|
proxy_redirect off;
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
proxy_read_timeout 3600s;
|
|
proxy_send_timeout 3600s;
|
|
}
|
|
}
|
|
NGINX'
|
|
|
|
echo ""
|
|
echo "=== 3. Test + reload ==="
|
|
ssh root@193.233.210.184 'nginx -t && systemctl reload nginx && echo OK'
|
|
|
|
echo ""
|
|
echo "=== 4. Curl tests ==="
|
|
ssh root@193.233.210.184 'curl -s -o /dev/null -w "VPS: code=%{http_code}\n" -m 10 https://vault.buryans.ru/'
|
|
pct exec 107 -- curl -s -o /dev/null -w "CT107: code=%{http_code}\n" -m 10 https://vault.buryans.ru/
|