From 9cc41753034a9576a2ef06e8a32b9bdf92cc47f6 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 28 May 2020 23:40:11 -0400 Subject: [PATCH] Add nginx configuration. Closes #1405 --- conf/nginx/http.conf | 49 ++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 9 ++++++++ 2 files changed, 58 insertions(+) create mode 100644 conf/nginx/http.conf diff --git a/conf/nginx/http.conf b/conf/nginx/http.conf new file mode 100644 index 00000000..246dab18 --- /dev/null +++ b/conf/nginx/http.conf @@ -0,0 +1,49 @@ +worker_processes 4; + +events { + + worker_connections 1024; +} + +http { + + # Configuration containing list of application servers + upstream app_servers { + + server ctfd:8000; + } + + server { + + listen 80; + + client_max_body_size 4G; + + # Handle Server Sent Events for Notifications + location /events { + + proxy_pass http://app_servers; + proxy_set_header Connection ''; + proxy_http_version 1.1; + chunked_transfer_encoding off; + proxy_buffering off; + proxy_cache off; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + } + + # Proxy connections to the application servers + location / { + + proxy_pass http://app_servers; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + } + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 89f81e64..ef58e289 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,6 +25,15 @@ services: default: internal: + nginx: + image: nginx:1.17 + volumes: + - ./conf/nginx/http.conf:/etc/nginx/nginx.conf + ports: + - 80:80 + depends_on: + - ctfd + db: image: mariadb:10.4.12 restart: always