#!/bin/bash set -e echo "=== Какие сертификаты есть на VPS? ===" ssh root@193.233.210.184 'ls -la /etc/letsencrypt/live/ 2>/dev/null || echo "no letsencrypt"; ls -la /etc/nginx/ssl/ 2>/dev/null || echo "no /etc/nginx/ssl"' echo "" echo "=== Создаём self-signed для IP 193.233.210.184 ===" ssh root@193.233.210.184 'mkdir -p /etc/nginx/ssl && openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \ -keyout /etc/nginx/ssl/tg-proxy.key \ -out /etc/nginx/ssl/tg-proxy.crt \ -subj "/CN=193.233.210.184" \ -addext "subjectAltName=IP:193.233.210.184" 2>/dev/null && echo "self-signed created"' echo "" echo "=== Обновляем nginx конфиг с self-signed ===" ssh root@193.233.210.184 'cat > /etc/nginx/sites-available/tg-proxy.conf << '"'"'CONF'"'"' server { listen 443 ssl; http2 on; server_name 193.233.210.184; ssl_certificate /etc/nginx/ssl/tg-proxy.crt; ssl_certificate_key /etc/nginx/ssl/tg-proxy.key; location /tg-api/ { proxy_pass https://api.telegram.org/; proxy_set_header Host api.telegram.org; proxy_ssl_server_name on; proxy_buffering off; } } CONF nginx -t && systemctl reload nginx && echo "nginx reloaded"' echo "" echo "=== Тест: CT108 -> VPS:443/tg-api/ (с -k для self-signed) ===" pct exec 108 -- curl -s -k -m 10 -o /dev/null -w "NGINX_PROXY: code=%{http_code}\n" \ https://193.233.210.184/tg-api/ || echo "FAIL nginx proxy" echo "" echo "=== Тест: getMe через proxy ===" pct exec 108 -- curl -s -k -m 10 \ https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/getMe | jq -r '.ok // "error"' || echo "FAIL getMe"