mirror of
https://github.com/sergeyyarkov/node-docker-example.git
synced 2026-10-11 02:09:22 +03:00
feat: added nginx container
This commit is contained in:
parent
2a4197ab42
commit
1a66780399
@ -1,8 +1,18 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
nginx:
|
||||||
|
container_name: nginx
|
||||||
|
restart: always
|
||||||
|
image: nginx:latest
|
||||||
|
volumes:
|
||||||
|
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
backend:
|
backend:
|
||||||
container_name: node-docker-example
|
container_name: nodejs
|
||||||
restart: always
|
restart: always
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
|
|||||||
2
env.js
2
env.js
@ -6,7 +6,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
app: {
|
app: {
|
||||||
port: parseInt(process.env.PORT, 10),
|
port: parseInt(process.env.PORT, 10) || 4000,
|
||||||
},
|
},
|
||||||
db: {
|
db: {
|
||||||
user: process.env.PG_USER.toString(),
|
user: process.env.PG_USER.toString(),
|
||||||
|
|||||||
17
nginx/default.conf
Normal file
17
nginx/default.conf
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://nodejs:4000;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user