[英]Docker NGINX Reverse Proxy 502 Bad Gateway on VM
I am trying to setup a Gitea instance on a VM.我正在尝试在 VM 上设置 Gitea 实例。 For that I am using docker-compose.为此,我正在使用 docker-compose。
Now my problem is, that i run my VM and docker-compose but I can't reach the webapp.现在我的问题是,我运行我的虚拟机和 docker-compose 但我无法访问 webapp。 The browser prompts me with a 502 Bad Gateway
.浏览器提示我502 Bad Gateway
。
The IP for my VM is: 192.168.33.10.我的虚拟机的 IP 是:192.168.33.10。 In the browser I am typing in 192.168.33.10:80
在浏览器中,我输入192.168.33.10:80
The docker logs production_nginx
provides me with the following output: docker logs production_nginx
为我提供了以下 output:
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"
However I don't understand what is happening here... Any advide is highly appreciated.但是我不明白这里发生了什么......任何建议都非常感谢。
My docker-compose.yml:我的 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: {}
My nginx.conf:我的 nginx.conf:
events {}
http {
upstream gitea{
server gitea_server:3000;
}
server {
listen 80;
location / {
proxy_pass http://gitea;
}
}
}
It seems like the user inside the gitea
image is not allowed to use ports <= 1023.似乎不允许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
Just put HTTP_PORT=3000
and you are good to go.只需HTTP_PORT=3000
就可以了 go。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.