Browse Source

fix problem because identical images names in docker-compose.yml, add load-blancing

master
anonstudent 7 months ago
parent
commit
3aeb6e0efe
  1. 44
      docker-compose.yml
  2. 2
      frontend-nginx/html/index.html
  3. 4
      frontend-nginx2/Dockerfile
  4. 54
      frontend-nginx2/etc/nginx/conf.d/default.conf
  5. 15
      frontend-nginx2/html/add-client.html
  6. 16
      frontend-nginx2/html/change-client-money.html
  7. 15
      frontend-nginx2/html/delete-client.html
  8. 15
      frontend-nginx2/html/index.html
  9. 4
      frontend-nginx3/Dockerfile
  10. 54
      frontend-nginx3/etc/nginx/conf.d/default.conf
  11. 15
      frontend-nginx3/html/add-client.html
  12. 16
      frontend-nginx3/html/change-client-money.html
  13. 15
      frontend-nginx3/html/delete-client.html
  14. 15
      frontend-nginx3/html/index.html
  15. 5
      loadbalancer-nginx/Dockerfile
  16. 13
      loadbalancer-nginx/etc/nginx/conf.d/default.conf

44
docker-compose.yml

@ -1,12 +1,36 @@ @@ -1,12 +1,36 @@
version: "3"
services:
loadbalancer-nginx:
image: docker/nginx-lb
build: ./loadbalancer-nginx
container_name: loadbalancer-nginx
ports:
- 80:80
networks:
- front
- back
frontend-nginx:
image: nginx
image: docker/nginx
build: ./frontend-nginx
container_name: frontend-nginx
ports:
- 80:80
networks:
- front
- back
frontend-nginx2:
image: docker/nginx2
build: ./frontend-nginx2
container_name: frontend-nginx2
networks:
- front
- back
frontend-nginx3:
image: docker/nginx3
build: ./frontend-nginx3
container_name: frontend-nginx3
networks:
- front
- back
@ -18,6 +42,20 @@ services: @@ -18,6 +42,20 @@ services:
networks:
- back
backend-fcgiwrap2:
image: docker/fcgiwrap
build: ./backend-fcgiwrap
container_name: backend-fcgiwrap2
networks:
- back
backend-fcgiwrap3:
image: docker/fcgiwrap
build: ./backend-fcgiwrap
container_name: backend-fcgiwrap3
networks:
- back
db-tarantool:
image: docker/tarantool
build: ./db-tarantool

2
frontend-nginx/html/index.html

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<title>Simple bank</title>
</head>
<body>
<p>Привет!</p>
<p>Привет! (1 сервер)</p>
<a href="add-client.html">Зарегистрировать нового клиента</a>
<a href="/cgi-bin/show-all.py">Показать список клиентов</a>
<a href="/change-client-money.html">Изменить количество денег у клиента</a>

4
frontend-nginx2/Dockerfile

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
FROM nginx:latest
COPY ./etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY ./html /usr/share/nginx/html

54
frontend-nginx2/etc/nginx/conf.d/default.conf

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location /cgi-bin/ {
fastcgi_pass backend-fcgiwrap2:9000;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
include /etc/nginx/fastcgi_params;
}
#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;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

15
frontend-nginx2/html/add-client.html

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Добавляем клиента</p>
<form action="/cgi-bin/add-client.py" method="post">
<input type="text" id="name" name="user_name">
<input type="submit" value="Submit">
</form>
</body>
</html>

16
frontend-nginx2/html/change-client-money.html

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Изменяем количество денег у клиента (укажите Имя, +/-n денег)</p>
<form action="/cgi-bin/change-client-money.py" method="post">
<input type="text" id="name" name="user_name">
<input type="text" id="change" name="change">
<input type="submit" value="Submit">
</form>
</body>
</html>

15
frontend-nginx2/html/delete-client.html

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Закрываем счёт клиента клиента</p>
<form action="/cgi-bin/delete-client.py" method="post">
<input type="text" id="name" name="user_name">
<input type="submit" value="Submit">
</form>
</body>
</html>

15
frontend-nginx2/html/index.html

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Привет! (2 сервер)</p>
<a href="add-client.html">Зарегистрировать нового клиента</a>
<a href="/cgi-bin/show-all.py">Показать список клиентов</a>
<a href="/change-client-money.html">Изменить количество денег у клиента</a>
<a href="/delete-client.html">Закрыть счёт клиента</a>
</body>
</html>

4
frontend-nginx3/Dockerfile

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
FROM nginx:latest
COPY ./etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY ./html /usr/share/nginx/html

54
frontend-nginx3/etc/nginx/conf.d/default.conf

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location /cgi-bin/ {
fastcgi_pass backend-fcgiwrap3:9000;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
include /etc/nginx/fastcgi_params;
}
#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;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

15
frontend-nginx3/html/add-client.html

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Добавляем клиента</p>
<form action="/cgi-bin/add-client.py" method="post">
<input type="text" id="name" name="user_name">
<input type="submit" value="Submit">
</form>
</body>
</html>

16
frontend-nginx3/html/change-client-money.html

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Изменяем количество денег у клиента (укажите Имя, +/-n денег)</p>
<form action="/cgi-bin/change-client-money.py" method="post">
<input type="text" id="name" name="user_name">
<input type="text" id="change" name="change">
<input type="submit" value="Submit">
</form>
</body>
</html>

15
frontend-nginx3/html/delete-client.html

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Закрываем счёт клиента клиента</p>
<form action="/cgi-bin/delete-client.py" method="post">
<input type="text" id="name" name="user_name">
<input type="submit" value="Submit">
</form>
</body>
</html>

15
frontend-nginx3/html/index.html

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple bank</title>
</head>
<body>
<p>Привет! (3 сервер)</p>
<a href="add-client.html">Зарегистрировать нового клиента</a>
<a href="/cgi-bin/show-all.py">Показать список клиентов</a>
<a href="/change-client-money.html">Изменить количество денег у клиента</a>
<a href="/delete-client.html">Закрыть счёт клиента</a>
</body>
</html>

5
loadbalancer-nginx/Dockerfile

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY ./etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf

13
loadbalancer-nginx/etc/nginx/conf.d/default.conf

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
upstream frontends {
server frontend-nginx:80;
server frontend-nginx2:80;
server frontend-nginx3:80;
}
server {
listen 80;
listen [::]:80;
location / {
proxy_pass http://frontends;
}
}
Loading…
Cancel
Save