【发布时间】:2021-06-03 01:09:20
【问题描述】:
我正在使用 docker compose 运行最新版本的 nginx,使用卷我将 nginx.conf 文件复制到 nginx docker 容器中
nginx:
image: nginx:1.20
container_name: nginx
ports:
- 80:80
restart: unless-stopped
volumes:
- ./nginx/nginx.conf:/etc/nginx/default.conf
depends_on:
- strapi
- rocketchat
- keycloak
networks:
- test-network
每个应用程序都在同一个网络上运行。
这里是 nginx.conf 文件
events {
worker_connections 4096; ## Default: 1024
}
http {
server {
listen 80;
server_name qa.xxx.com;
location / {
proxy_pass http://strapi-container:1337/;
}
location /chat {
proxy_pass http://rocketchat-container:3000;
}
location /auth {
proxy_pass http://keycloak-container:8080;
proxy_set_header Host $host;
}
}
}
我的意图是使用 nginx 配置运行三个后端 URL /、/chat、/auth。在实例上运行应用程序时,http://ip-address/chat、http://ip-address/auth 似乎不起作用
这里是 nginx 日志错误
2021/06/02 07:46:42 [error] 31#31: *1 open() "/usr/share/nginx/html/chat" failed (2: No such file or directory), client: 115.96.103.237, server: localhost, request: "GET /chat HTTP/1.1", host: "310.28.67.222"
115.96.103.237 - - [02/Jun/2021:07:46:42 +0000] "GET /chat HTTP/1.1" 404 555 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" "-"
2021/06/02 07:46:50 [error] 31#31: *2 open() "/usr/share/nginx/html/auth" failed (2: No such file or directory), client: 115.96.103.237, server: localhost, request: "GET /auth HTTP/1.1", host: "310.28.67.222"
115.96.103.237 - - [02/Jun/2021:07:46:50 +0000] "GET /auth HTTP/1.1" 404 555 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" "-"
【问题讨论】:
-
使用
nginx -T(大写T)查看所有包含文件的完整配置。错误信息与您发布的配置文件不一致。该错误对应于server_name localhost和notserver_name qa.xxx.com。
标签: docker nginx nginx-reverse-proxy nginx-config nginx-location