Хотелось бы уточнить, всё ли верно я сделал. Сайт был на HTTP. Купил домен, зарегал сертификат в Let's Encrypt. Сделал проброс с http на https. В браузере вроде даже показывает всё верно, но вот в логах мелькает, что это HTTP 1.0.
Конфиг nginx
Домен заменён на example
server {
server_name example.ru www.example.ru;
location / {
proxy_pass https://127.0.0.1:9123;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ($scheme = http) {
return 301 https://$host$request_uri;
}
}
location /ws/ {
proxy_pass https://127.0.0.1:9123;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ($scheme = http) {
return 301 https://$host$request_uri;
}
}
error_log /var/log/nginx/example_error.log;
access_log /var/log/nginx/example_access.log;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.ru/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 = www.example.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name example.ru www.example.ru;
return 404; # managed by Certbot
}
Логи
Серверная часть
app = FastAPI()
app.state.limiter = limiter
app.add_middleware(HTTPSRedirectMiddleware)
app.add_middleware(SessionMiddleware, secret_key=SECRET_KEY, same_site="Strict", https_only=True)
app.add_middleware(TrustedHostMiddleware, allowed_hosts=["example.ru", "*.example.ru", "127.0.0.1"])
templates = Jinja2Templates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def dashboard(request: Request):
"""Главная страница с проверкой авторизации."""
user = get_current_user(request)
if not user:
return RedirectResponse(url="/login")
style_output = copy.deepcopy(online_clients)
for client_id, client_obj in online_clients.items():
last_seen_time = datetime.strptime(client_obj['last_seen'], "%Y-%m-%d %H:%M:%S")
time_diff = datetime.now() - last_seen_time
style_output[client_id]['last_seen'] = humanize.naturaltime(time_diff, )
return templates.TemplateResponse("index.html", {"request": request, "clients": style_output, "user": user})
@app.get("/login", response_class=HTMLResponse)
async def login_page(request: Request):
"""Страница авторизации."""
return templates.TemplateResponse("login.html", {"request": request, "error": None})
if __name__ == "__main__":
uvicorn.run(
app,
host="0.0.0.0",
port=9123,
ssl_keyfile="privkey.pem",
ssl_certfile="cert.pem"
)
Это чисто визуальная проблема или я что-то упускаю?