0

I am new to telegram bots developing, currently I am trying to make bot using aiogram and webhooks. Here my configuraton of domain:

server {
    server_name my_server my_server;
    add_header Access-Control-Allow-Origin *;
    add_header Cross-Origin-Opener-Policy unsafe-none;
    location / {
        proxy_pass http://127.0.0.1:8000/;
}
    location @fallback {
    proxy_pass http://127.0.0.1:8000;
    proxy_redirect http://127.0.0.1:8000/ /;
    }
    
    location /static {
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8000/static;
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/my_server/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/my_server/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = my_server) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = my_server) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name my_server www.my_server;
    listen 80;
    return 404; # managed by Certbot




}

And here my main code:

token = Configurator_yml().get_bot_token()
bot = Bot(token)
dp = Dispatcher(bot)
WEBHOOK_DOMAIN = "MY DOMAIN"
WEBAPP_HOST = "127.0.0.1"
WEBAPP_PORT = "8000"


async def on_startup(dp):
    await bot.set_webhook(WEBHOOK_DOMAIN, drop_pending_updates=True)


async def on_shutdown(dp):
    await bot.delete_webhook()
if __name__ == "__main__":
    from aiogram import executor

    #     # set_bd()
    start_webhook(
        dispatcher=dp,
        webhook_path="",
        on_startup=on_startup,
        on_shutdown=on_shutdown,
        skip_updates=True,
        host=WEBAPP_HOST,
        port=WEBAPP_PORT,
    )

In /var/log/nginx/access.log

"POST / HTTP/1.1" 502 166 "-" "-"

Seems that telegram can reach webserver, but gets 502. How can I solve this problem? Before it, telegram API can't reach my server at all due to ports, now I have opened 443 and 80 for everything, including Nginx HTTP/HTTPS/Full, OpenSSH

Vivern202
  • 29
  • 3
  • 7

0 Answers0