E
E
Evgeny Petrov2020-08-26 21:09:48
Nginx
Evgeny Petrov, 2020-08-26 21:09:48

Why does the telegram bot work on local, but not on the server?

Hello!

I wrote a telegram bot on telegraf.js, tested it locally with ngrok, everything works fine. I bought a VPS, raised a server to nginx + set up the node certificates, I'm running it. BUT! getWebhookInfo throws an error: Wrong response from the webhook: 502 Bad Gateway .
Checked the error.log:
Error: upstream prematurely closed connection while reading response header from upstream
The node is closing the connection prematurely. Shoveled everything I could, but the error is the same.

nginx/sites-available/default config:

server {
        listen 443 ssl;
        ssl_certificate /path/to/cert.crt;
        ssl_certificate_key /path/to/cert_key.key;
        server_name infocardbot.dreamcode.kz;

        location /hook {
                proxy_connect_timeout 90s;
                proxy_send_timeout 120s;
                proxy_read_timeout 120s;
                proxy_pass http://127.0.0.1:4000;
                proxy_http_version 1.1;
                proxy_set_header Host $host;
                proxy_redirect off;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Host $server_name;
        }
}


URL-webhook: https://infocardbot.dreamcode.kz/hook

I think the code of the bot itself is not required, since it works on the local, so it's not the case.
I'm not asking for a ready answer, please give at least a direction.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question