Skip to content

Commit

Permalink
chore: add load balancing in proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
louischarnay committed Feb 8, 2024
1 parent 8db4cc0 commit 11d8924
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
8 changes: 6 additions & 2 deletions TP01/web/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,12 @@ SSLRandomSeed connect builtin
Header set Access-Control-Allow-Origin *
ProxyRequests On
ProxyPreserveHost On
ProxyPass /api http://backend:8080/
ProxyPassReverse /api http://backend:8080/
<Proxy "http://serverpool">
BalancerMember "http://backend-1:8080"
BalancerMember "http://backend-2:8080"
</Proxy>
ProxyPass "/api/" "http://serverpool"
ProxyPassReverse "/api/" "http://serverpool"
ProxyPass / http://frontend:80/
ProxyPassReverse / http://frontend:80/
</VirtualHost>
Expand Down
20 changes: 15 additions & 5 deletions TP03/ansible/roles/launch-app/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
---
# tasks file for roles/launch-app
- name: Run App
- name: Run App-1
docker_container:
name: "{{ BACKEND_NAME}}"
name: "{{ BACKEND_NAME}}-1"
image: "{{ BACKEND_IMAGE }}"
state: started
state: absent
env:
DATABASE_URL: "{{ DATABASE_URL }}"
POSTGRES_USER: "{{ POSTGRES_USER }}"
POSTGRES_PASSWORD: "{{ POSTGRES_PASSWORD }}"
POSTGRES_DB: "{{ POSTGRES_DB }}"
networks:
- name: "{{ NETWORK_NAME }}"
ports:
- "8080:8080"
- name: Run App-2
docker_container:
name: "{{ BACKEND_NAME}}-2"
image: "{{ BACKEND_IMAGE }}"
state: absent
env:
DATABASE_URL: "{{ DATABASE_URL }}"
POSTGRES_USER: "{{ POSTGRES_USER }}"
POSTGRES_PASSWORD: "{{ POSTGRES_PASSWORD }}"
POSTGRES_DB: "{{ POSTGRES_DB }}"
networks:
- name: "{{ NETWORK_NAME }}"
2 changes: 1 addition & 1 deletion TP03/ansible/roles/launch-database/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
docker_container:
name: "{{ DATABASE_NAME }}"
image: "{{ DATABASE_IMAGE }}"
state: started
state: absent
env:
POSTGRES_DB: "{{ POSTGRES_DB }}"
POSTGRES_USER: "{{ POSTGRES_USER }}"
Expand Down
2 changes: 1 addition & 1 deletion TP03/ansible/roles/launch-front/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
docker_container:
name: "{{ FRONTEND_NAME }}"
image: "{{ FRONTEND_IMAGE }}"
state: started
state: absent
networks:
- name: "{{ NETWORK_NAME }}"
2 changes: 1 addition & 1 deletion TP03/ansible/roles/launch-proxy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
docker_container:
name: "{{ HTTPD_NAME }}"
image: "{{ HTTPD_IMAGE }}"
state: started
state: absent
networks:
- name: "{{ NETWORK_NAME }}"
ports:
Expand Down
2 changes: 1 addition & 1 deletion TP03/devops-front-main/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VUE_APP_API_URL=louis.charnay.takima.cloud/api
VUE_APP_API_URL=louis.charnay.takima.cloud:80/api

0 comments on commit 11d8924

Please sign in to comment.