我正在尝试在VM上设置Gitea实例。 为此,我正在使用docker-compose。
现在我的问题是,我运行我的VM和docker-compose,但无法访问Webapp。浏览器用502 Bad Gateway
提示我。
我的VM的IP为:192.168.33.10。
在浏览器中,我输入192.168.33.10:80
docker logs production_nginx
为我提供了以下输出:
2020/06/23 14:26:11 [error] 28#28: *7 connect() failed
(111: Connection refused) while connecting to upstream,
client: 192.168.33.1, server: , request: "GET /
HTTP/1.1", upstream: "http://172.27.0.2:3000/", host:
"192.168.33.10"
192.168.33.1 - - [23/Jun/2020:14:26:11 +0000] "GET /
HTTP/1.1" 502 157 "-" "Mozilla/5.0 (X11; Ubuntu; Linux
x86_64; rv:77.0) Gecko/20100101 Firefox/77.0"
但是我不明白这里发生了什么... 任何建议都会受到高度赞赏。
我的docker-compose.yml:
version: "2"
networks:
proxy:
gitea:
external: false
services:
nginx:
image: nginx:latest
container_name: production_nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
- "443:443"
- "222:22"
networks:
- proxy
server:
container_name: gitea_server
image: gitea/gitea:latest
environment:
- APP_NAME=Gitea
- USER_UID=1000
- USER_GID=1000
- DB_TYPE=postgres
- DB_HOST=db:5432
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD=gitea
- DOMAIN=localhost
- SSH_DOMAIN=localhost
- HTTP_PORT=80
- SSH_PORT=22
- SSH_LISTEN_PORT=22
restart: always
networks:
gitea:
aliases:
- gitea_server
proxy:
aliases:
- gitea_server
volumes:
- gitea_data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
expose:
- "3000"
- "2222"
depends_on:
- db
db:
container_name: postgres
image: postgres:9.6
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- postgres:/var/lib/postgresql/data
volumes:
gitea_data: {}
postgres: {}
我的nginx.conf:
events {}
http {
upstream gitea{
server gitea_server:3000;
}
server {
listen 80;
location / {
proxy_pass http://gitea;
}
}
}
答案 0 :(得分:1)
似乎gitea
图像内的用户不允许使用端口<= 1023。
server_1 | 2020/06/23 17:20:49 ...s/graceful/server.go:55:NewServer() [I] Starting new server: tcp:0.0.0.0:80 on PID: 14
server_1 | 2020/06/23 17:20:49 ...s/graceful/server.go:79:ListenAndServe() [E] Unable to GetListener: listen tcp 0.0.0.0:80: bind: permission denied
server_1 | 2020/06/23 17:20:49 cmd/web.go:204:runWeb() [C] Failed to start server: listen tcp 0.0.0.0:80: bind: permission denied
server_1 | 2020/06/23 17:20:49 cmd/web.go:206:runWeb() [I] HTTP Listener: 0.0.0.0:80 Closed
只需放置HTTP_PORT=3000
,您就可以使用了。