Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CloudComputing_Act1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jesus Galaz Reyes
CloudComputing_Act1
Commits
2b1adef3
Commit
2b1adef3
authored
4 months ago
by
Rokas Stankunas
Browse files
Options
Downloads
Patches
Plain Diff
feat: implement nginx load balancer
parent
13f79cc7
Branches
18-exercise-3-scaling-additional-features
Branches containing commit
No related tags found
1 merge request
!13
feat: implement nginx load balancer
Pipeline
#16880
passed
4 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docker-compose.yml
+13
-2
13 additions, 2 deletions
docker-compose.yml
nginx.conf
+38
-0
38 additions, 0 deletions
nginx.conf
with
51 additions
and
2 deletions
docker-compose.yml
+
13
−
2
View file @
2b1adef3
version
:
'
3.9'
services
:
mongodb
:
image
:
mongo:latest
...
...
@@ -33,4 +32,16 @@ services:
depends_on
:
-
mongodb
environment
:
-
MONGO_URI=${MONGO_URI}
\ No newline at end of file
-
MONGO_URI=${MONGO_URI}
nginx
:
image
:
nginx:latest
container_name
:
nginx
ports
:
-
"
80:80"
depends_on
:
-
todo-app-1
-
todo-app-2
volumes
:
-
"
./nginx.conf:/etc/nginx/nginx.conf:ro"
-
"
/var/log/nginx/access.log:/var/log/nginx/access.log"
This diff is collapsed.
Click to expand it.
nginx.conf
0 → 100644
+
38
−
0
View file @
2b1adef3
events
{
# Set the maximum number of simultaneous connections that can be opened by a worker process
worker_connections
1024
;
}
http
{
# Define an upstream group for load balancing the todo-app services
upstream
todo-app
{
ip_hash
;
server
todo-app-1
:
3000
;
# First server in the upstream group
server
todo-app-2
:
3000
;
# Second server in the upstream group
}
# Define a custom log format for capturing upstream request details
log_format
upstreamlog
'[
$time_local
]
$remote_addr
-
$remote_user
-
$request
'
'"
$status
"
$body_bytes_sent
'
'"
$http_referer
"
"
$http_user_agent
"
'
'"
$gzip_ratio
"
'
'
$
{
host
}
$request_uri
'
'
$upstream_addr
'
;
server
{
listen
80
;
# Listen on port 80 for incoming HTTP requests
location
/
{
# Proxy requests to the upstream todo-app group
proxy_pass
http://todo-app
;
proxy_http_version
1.1
;
# Use HTTP/1.1 for proxying
proxy_set_header
Upgrade
$http_upgrade
;
# Set the Upgrade header
proxy_set_header
Connection
'upgrade'
;
# Set the Connection header to upgrade
proxy_set_header
Host
$host
;
# Forward the original Host header
proxy_cache_bypass
$http_upgrade
;
# Bypass cache for upgraded requests
# Log access requests using the defined upstream log format
access_log
/var/log/nginx/access.log
upstreamlog
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment