Feat: change network

This commit is contained in:
koh 2023-05-09 16:00:18 +07:00
parent d106ff79f2
commit adcd663c38
3 changed files with 59 additions and 10 deletions

View File

@ -19,8 +19,8 @@ services:
env_file:
- .env
volumes:
- $PWD/init.sql:/docker-entrypoint-initdb.d/init.sql
- $PWD/mysql:/var/lib/mysql
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
- ./mysql:/var/lib/mysql
ports:
- $MYSQLDB_LOCAL_PORT:$MYSQLDB_DOCKER_PORT
networks:
@ -45,11 +45,15 @@ services:
command: bash -c "npm run dev"
nginx:
image: nginx:alpine
image: nginx
ports:
- 8000:80
- 80:80
links:
- node-app:node-app
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
restart: always
networks:
- backend
depends_on:

View File

@ -1,12 +1,18 @@
server {
client_max_body_size 25M;
listen 80;
listen [::]:80;
server_name 127.0.0.1;
# Logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_pass http://node-app:3000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
# max uploadable file size
client_max_body_size 4G;
}
}

39
nginx/nginx.conf Normal file
View File

@ -0,0 +1,39 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
limit_req_zone $binary_remote_addr zone=byip:10m rate=3r/s;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$request_time $upstream_response_time';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
#gzip on;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}