![](/img/trans.png)
[英]Problem with setting up a stack nginx proxy manager using portainer on my home server
[英]Setting up subdomains with nginx proxy manager
我正在尝试设置一个简单的 hello world flask 应用程序作为 nginx 代理管理器(NPM)后面的 docker 容器管理并通过子域访问。
我有 portainer 和 NPM 工作,我在我的路由器上暴露了端口 80 和 443,我已经设置了我的 cloudflare 域以使用 ddclient 指向我的 pi 来管理不断变化的 IP。 到目前为止,当我 go 到域时,我可以毫无问题地看到 npm 问候页面。
现在,我希望有人导航到子域,在本例中为 helloflask.mydomain.cloud。 它们将被指向一个 nginx/docker compose 应用程序。 但是还没有任何效果,当我尝试从 helloflask.mydomain.cloud url 访问它时,我看到的只是 502 个错误网关或“页面未正确重定向”,我不知道为什么或要检查什么要解决这个问题。
我可以通过端口8001本地连接到服务器就好了。
这是我当前 nginx 和 flask 容器的 docker 组合设置。
version: "3.7"
services:
flask:
build: ./flask
container_name: hello_world_flask
restart: always
environment:
- APP_NAME=MyFlaskApp
expose:
- 8080
nginx:
build: ./nginx
container_name: hello_world_flask_nginx
restart: always
ports:
- 8001:80
And my docker containers , hello_world_flask_default
is the docker network with the nginx and flask containers. 所以我把它放在我的NPM 代理主机中,带有详细信息和SSL 设置。 (也许是 https 问题?)
这是我的cloudflare 域设置。
谢谢!
这是你需要做的:
确保您的 nginx 代理管理器和您的 docker 容器在同一网络上运行。
那应该工作
您可以将网络放入 docker-compose 之类的东西
version: "3.7"
services:
flask:
build: ./flask
container_name: hello_world_flask
restart: always
environment:
- APP_NAME=MyFlaskApp
expose:
- 8080
nginx:
build: ./nginx
container_name: hello_world_flask_nginx
restart: always
networks:
default:
external:
name: proxy
确保您正确格式化 docker-compose.yml 文件,并确保 nginx 代理管理器和您的 flash 应用程序 ngnix 容器都属于同一个网络“代理”,但我认为您命名为一个反向代理点只是一个例子。
确保通过运行获得 nginx 容器的正确 IP 地址
docker 检查 your-flask-app-nginx-container-name/id
然后你会得到一个像这样的屏幕,你可以在其中获取该容器的正确 IP 地址
确保检查所有容器网络和 nginx 反向代理容器网络是否相同
然后像这样使用 nginx 反向代理添加代理
You can add the SSL settings on the SSL tab yourself:) also make sure to put the right IP address and don't copy from the screenshot because it won't work if you don't put the right IP address. 我认为这应该可行,因为我的服务器上没有任何问题,我使用相同的设置,让我知道,祝你好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.