Установил nginx + letsencrypt Добавил в файл nginx.config:
server {
listen 80;
listen 443 ssl;
server_name vm.example;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/letsencrypt/live/vm.example/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/vm.example/privkey.pem;
location / {
proxy_pass http://127.0.0.1:7771;
proxy_redirect off;
proxy_set_header Host $host;
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;
}
}
Пытаюсь запустить python-скрипт:
import aiogram
BOT_TOKEN = "Тут был токен"
# webhook settings
WEBHOOK_HOST = 'https://vm.example'
WEBHOOK_PATH = '/'
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}"
# webserver settings
WEBAPP_HOST = '127.0.0.1'
WEBAPP_PORT = 7771
bot = aiogram.Bot(token=BOT_TOKEN)
dp = aiogram.Dispatcher(bot=bot)
@dp.message_handler(commands=['start'])
async def start(message: aiogram.types.Message):
await message.answer(text="Hello!")
async def on_startup(dp):
await bot.set_webhook(WEBHOOK_URL)
async def on_shutdown(dp):
await bot.delete_webhook()
if name == 'main':
aiogram.executor.start_webhook(
dispatcher=dp,
webhook_path=WEBHOOK_PATH,
on_startup=on_startup,
on_shutdown=on_shutdown,
skip_updates=True,
host=WEBAPP_HOST,
port=WEBAPP_PORT,
)
Скрипт запускается, но бот не видит сообщений. Подскажите, в чем проблема?