我试着在码头上运行nginx,并将它连接到docker中的一个服务。另一个服务正在运行,没有码头,也使用这个nginx。我的船坞-写作:
version: "3.9"
services:
nginx:
restart: always
image: nginx
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "3000:80"
- "9000:81"
web:
restart: always
image: "xxxx/xxxx/web"和./config/nginx.conf的nginx conf
events {}
http{
upstream ws-api {
server host.docker.internal:8081;
}
upstream ws-web {
server web;
}
server {
server_name localhost;
listen 80;
location / {
include fastcgi_params;
fastcgi_split_path_info ^(/)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_pass ws-api;
}
}
server {
server_name localhost;
listen 81;
location / {
include fastcgi_params;
proxy_pass http://ws-web;
}
location /api {
rewrite ^([^.]*[^/])$ $1/;
rewrite ^/api(.*)$ $1 break;
include fastcgi_params;
fastcgi_split_path_info ^(/)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_pass ws-api;
}
}
}当我打开localhost:9000时,会收到错误消息:
查找ws-web上的192.168.65.5:53:没有这样的主机
本地主机:3000个工作很好
我犯了什么错?
发布于 2021-04-02 16:02:36
将Docker更新到最新的苹果硅预览版,为我修复了它。
发布于 2021-11-22 00:16:53
不是严格意义上的话题。但是,我面对这个神奇的IP响应,同时连接我的nginx服务在minikube (码头VM)。并且错误地期望服务域名被minikube的DNS解析成完整的IP:端口地址。因此,重点是在proxy_pass中添加端口:proxy_pass。
https://stackoverflow.com/questions/66804528
复制相似问题