mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
load balancer example
This commit is contained in:
parent
222426854e
commit
6a22f7711c
6 changed files with 88 additions and 0 deletions
39
examples/load-balancer/docker-compose.yml
Normal file
39
examples/load-balancer/docker-compose.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
|
||||
myreverse:
|
||||
image: bunkerity/bunkerized-nginx
|
||||
restart: always
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
volumes:
|
||||
- ./letsencrypt:/etc/letsencrypt
|
||||
- ./http-confs:/http-confs
|
||||
- ./server-confs:/server-confs
|
||||
environment:
|
||||
- SERVER_NAME=www.website.com # replace with your domain
|
||||
- SERVE_FILES=no
|
||||
- DISABLE_DEFAULT_SERVER=yes
|
||||
- REDIRECT_HTTP_TO_HTTPS=yes
|
||||
- AUTO_LETS_ENCRYPT=yes
|
||||
|
||||
app1:
|
||||
build: js-app
|
||||
restart: always
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
|
||||
app2:
|
||||
build: js-app
|
||||
restart: always
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
|
||||
app3:
|
||||
build: js-app
|
||||
restart: always
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
|
5
examples/load-balancer/http-confs/upstream.conf
Normal file
5
examples/load-balancer/http-confs/upstream.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
upstream app {
|
||||
server app1:3000;
|
||||
server app2:3000;
|
||||
server app3:3000;
|
||||
}
|
11
examples/load-balancer/js-app/Dockerfile
Normal file
11
examples/load-balancer/js-app/Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
|||
FROM node
|
||||
|
||||
COPY app/ /home/node/app
|
||||
|
||||
RUN cd /home/node/app && npm install && chown -R root:node /home/node/app && chmod -R 770 /home/node/app
|
||||
|
||||
WORKDIR /home/node/app
|
||||
|
||||
USER node
|
||||
|
||||
CMD ["node", "index.js"]
|
13
examples/load-balancer/js-app/app/index.js
Normal file
13
examples/load-balancer/js-app/app/index.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
const express = require('express')
|
||||
const app = express()
|
||||
const port = 3000
|
||||
var os = require("os");
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Container id = ' + os.hostname())
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening at http://localhost:${port}`)
|
||||
})
|
||||
|
14
examples/load-balancer/js-app/app/package.json
Normal file
14
examples/load-balancer/js-app/app/package.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "js-app",
|
||||
"version": "1.0.0",
|
||||
"description": "demo",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.17.1"
|
||||
}
|
||||
}
|
6
examples/load-balancer/server-confs/reverse-proxy.conf
Normal file
6
examples/load-balancer/server-confs/reverse-proxy.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
location / {
|
||||
proxy_pass http://app$request_uri;
|
||||
}
|
Loading…
Reference in a new issue