gpt4 book ai didi

docker - Docker中的503服务暂时不可用nginx/1.13.3

转载 作者:行者123 更新时间:2023-12-02 19:35:31 25 4
gpt4 key购买 nike

我正在尝试使用jwilder/nginx-proxy: alpine来启动nginx,以下是docker run命令和步骤:

步骤1 :docker run -d -p 80:80 -p 443:443 -v /var/run/docker.sock:/tmp/docker.sock:ro --name nginx jwilder/nginx-proxy:alpine
步骤2 :在ec2实例的安全组中打开了端口80,并尝试连接到ip:80/,但错误如下: 503服务暂时不可用nginx / 1.13.3

docker 日志说:

WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one
is being generated in the background. Once the new dhparam.pem is in place, nginx will be reloaded.
forego | starting dockergen.1 on port 5000
Generating DH parameters, 2048 bit long safe prime, generator 2
forego | starting nginx.1 on port 5100
dockergen.1 | 2017/08/14 13:45:44 Generated '/etc/nginx/conf.d/default.conf' from 4 containers
dockergen.1 | 2017/08/14 13:45:44 Running 'nginx -s reload'
dockergen.1 | 2017/08/14 13:45:44 Watching docker events
dockergen.1 | 2017/08/14 13:45:44 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx.1 | ec2-xx.xx.xxx.xx..ap-xyz-5.compute.amazonaws.com xx.xxx.xxx.x - "GET / HTTP/1.1" 503 615 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"
nginx.1 | ec2-xx.xxx.xxxx.xxx.ap-xyz-5.compute.amazonaws.com xx.xx.xx.xxx "GET /favicon.ico HTTP/1.1" 503 615 "http://ec2-xx.xxx.xx.xx.ap-xyz-5.compute.amazonaws.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"

最佳答案

单独运行jwilder/nginx-proxy并没有多大意义。魔术背后的脚本检查其他容器环境变量,并生成相应的规则,以将代理从hostname from another container as defined in env var : port defined the same way反向转换为所述容器和端口。

此处的键是“来自另一个容器的主机名”。当您尝试使用您所说的IP连接时,Nginx不会代理转发您。

这是来自jwielder / nginx的github存储库中的README.md的示例

version: '2'

services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

whoami:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=whoami.local <================

运行此命令,编辑主机文件(类似于 sudo vim /etc/hosts),添加 [ec2ip] whoami.local,然后打开浏览器以查找 http://whoami.local,这样就可以了。

关于docker - Docker中的503服务暂时不可用nginx/1.13.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45675976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com