我已经尝试了一切:
@小星:
routes = [
Mount("/static/", StaticFiles(directory=parent+fs+"decoration"+fs+"static"), name="static"),
Route(....),
Route(....),
]
@Uvicorn:
--forwarded-allow-ips=domain.com
--proxy-headers
@url_for:
_external=True
_scheme="https"
@nginx:
proxy_set_header Subdomain $subdomain;
proxy_set_header Host $http_host;
proxy_pass http://localhost:7000/;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $server_name;
proxy_redirect http://$http_host/ https://$http_host/;
include proxy_params;
server {
if ($host = sub.domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name sub.domain.com;
return 404; # managed by Certbot
}
如果我打开 .css 或 .js 链接,nginx 会将其呈现为 https。
当我允许 Firefox 忽略不安全的内容时,整个页面会在生产服务器上正确呈现。
Let's encrypt 适用于整个域,证书没有问题。