我正在运行NOMAD进行集群管理,Consul和NGINX作为docker容器
我也在运行Tomcat作为NOMAD作业任务,它创建一个docker容器并在客户端上运行它。
我创建了nginx.conf文件,提供了上游功能和适当的代理传递。
但是 502 Bad Gateway错误。日志显示:
*1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.209.25.31, server: , request: "GET /tomcat/ HTTP/1.1", upstream: "http://127.0.0.1:65535/tomcat/", host: "10.209.25.36"
有人可以帮帮我吗。
PFB我的 nginx.conf
upstream app-tomcat {
least_conn;
{{range service "web-tomcat"}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;
{{else}}server 127.0.0.1:65535; # force a 502{{end}}
}
upstream app-finalkafka{
least_conn;
{{range service "web-finalkafka"}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;
{{else}}server 127.0.0.1:65535; # force a 502{{end}}
}
server {
listen 80;
location /tomcat {
proxy_pass http://app-tomcat;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /finalkafka/ {
proxy_pass http://app-finalkafka;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ \.(gif|jpg|png)$ {
root /data/images;
}
location / {
proxy_pass http://10.209.25.36:8500;
}
}