diff --git a/docker-compose.yml b/docker-compose.yml index 2d4e299..6f276af 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/nginx/default.conf b/nginx/default.conf index 461fb37..2bd21da 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -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; } } \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..f7e2af9 --- /dev/null +++ b/nginx/nginx.conf @@ -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/*; +} \ No newline at end of file