This project sets up a Round Robin load balancing system using Docker, Nginx, Go, and Laravel.
- Faced challenges in properly configuring the Go Docker image.
- Solution: Tweaked the Dockerfile to optimize the build process and dependencies.
- Faced difficulties in setting up Nginx to distribute requests evenly between Go and Laravel instances.
- Solution: Configured Nginx with appropriate upstream blocks and load balancing settings.
-
Encountered permission issues while trying to write to the Laravel
storagefolder. -
Solution: Manually granted permissions to the
www-datauser.sudo chown -R www-data:www-data storage/ sudo chmod -R 775 storage/
- Docker and Docker Compose installed.
- Basic knowledge of Docker, Nginx, and Laravel.
Use the following command to build the Docker images:
docker compose -f docker-compose.dev.yml -p dockerproject buildRun the following command to start all the services:
docker compose -f docker-compose.dev.yml -p dockerproject up- Laravel Application:
http://localhost - Go Application:
http://localhost:8080
Below is an example Nginx configuration for Round Robin load balancing:
upstream backend {
server app1:8000;
server app2:8000;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}- Stop running containers:
docker compose down
- Check running containers:
docker ps
- View logs:
docker compose logs -f
- Docker multi-stage builds for Go.
- Advanced Nginx load balancing techniques.
- Automating Laravel permission handling in Docker setup.
Thanks to Claude.AI for helping solve the challenges faced during setup.
Happy Coding!!