我是码头工人的新手。我已经完成了一些教程来创建 docker compose 文件来创建 3 个 Jetty、1 个 NGINX 和 1 个 MySQL。 NGINX 充当具有循环机制的 LB。它按预期工作良好。
如果我扩展我的jetty实例(通过docker-compose scale jetty-one = 2),则会创建容器。但它不属于 NGINX LB 的范畴。我希望,我已经在 NGINX 的上游配置文件中进行了硬编码。请指导我并提供在运行时在LB下添加Jetty实例而无需重新启动LB的解决方案。
Docker 组合
lb:
image: nginx
ports:
- "82:80"
volumes:
- /home/docker/default.conf:/etc/nginx/conf.d/default.conf
links:
- jetty-one:jetty1
- jetty-two:jetty2
- jetty-three:jetty3
jetty-one:
image: jetty
volumes:
- /home/docker/webapps:/var/lib/jetty/webapps
jetty-two:
image: jetty
volumes:
- /home/docker/webapps:/var/lib/jetty/webapps
jetty-three:
image: jetty
volumes:
- /home/docker/webapps:/var/lib/jetty/webapps
db:
image: mysql
ports:
- "3307:3306"
NGINX 配置文件
upstream backend {
server jetty1:8080;
server jetty2:8080;
server jetty3:8080;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
proxy_pass http://backend;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)