34 lines
1.2 KiB
Bash
Executable File
34 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
echo "=== Добавляем location /tg-api/ в nginx ==="
|
|
ssh root@193.233.210.184 'cat > /etc/nginx/sites-available/tg-proxy.conf << CONF
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name 193.233.210.184;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/buryans.ru/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/buryans.ru/privkey.pem;
|
|
|
|
location /tg-api/ {
|
|
proxy_pass https://api.telegram.org/;
|
|
proxy_set_header Host api.telegram.org;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_ssl_server_name on;
|
|
proxy_buffering off;
|
|
}
|
|
}
|
|
CONF
|
|
ln -sf /etc/nginx/sites-available/tg-proxy.conf /etc/nginx/sites-enabled/
|
|
nginx -t && systemctl reload nginx && echo "nginx reloaded"'
|
|
|
|
echo ""
|
|
echo "=== Тест: CT108 -> VPS:443/tg-api/ -> api.telegram.org ==="
|
|
pct exec 108 -- curl -s -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 "=== Тест: прямой запрос к Telegram через proxy ==="
|
|
pct exec 108 -- curl -s -m 10 \
|
|
https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/getMe | jq -r '.ok // "error"' || echo "FAIL getMe"
|