我已经在 Ubuntu 22.04 服务器上设置了 nginx 反向代理,并且已成功从 Lets Encrypt 获取 ssl 证书。两个密钥存储在这里:
/etc/letsencrypt/live/test.ddns.net/fullchain.pem;
/etc/letsencrypt/live/test.ddns.net/privkey.pem
Run Code Online (Sandbox Code Playgroud)
在我的默认 nginx 配置中,我有两个路径helloworld和portainer。两条路径都重定向到 docker 容器。
server {
listen 80;
listen [::]:80;
server_name test.ddns.net;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name test.ddns.net;
ssl_certificate /etc/letsencrypt/live/test.ddns.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.ddns.net/privkey.pem;
location /helloworld {
proxy_pass http://localhost:32768;
}
location /portainer {
proxy_pass http://localhost:9000;
}
Run Code Online (Sandbox Code Playgroud)
helloworld 路径按预期工作,并使用 https 协议加载 html 页面(因此我的 ngnix 配置是正确的)。但portainer路径不是。我尝试了端口 9000、端口 8000、端口 9443。但都不起作用。我收到 404 错误,或者通过 http 发送的请求,而预期是 https,或者其他错误。有没有人有相同的设置并且能够帮助我?
谢谢。