# Lab 10. System and Network administartion ## Timur Mustafin # Load balancing with nginx ### Load balancer #### Nginx config ``` http { upstream myapp1 { server node1; server node2; } server { listen 80; location / { proxy_pass http://myapp1; } } } events {} ``` #### Dockerfile ``` FROM nginx:latest COPY nginx.conf /etc/nginx/nginx.conf ``` ### Node #### Nginx uses default config (serves default page) #### Dockerfile ``` FROM nginx:latest ``` #### docker-compose ``` version: "3" services: node1: build: . ports: - 80 networks: - internal node2: build: . ports: - 80 networks: - internal nginx: build: nginx/ ports: - 80:80 networks: - internal networks: internal: ``` ## Verification start the service, both nodes are working  Destroy one node with `docker stop`  After a few 499(i updated the page in a browser) it always uses one node with normal 344 response 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up