Nginx Updated Configuration

This commit is contained in:
Price Hiller 2021-10-18 12:01:53 -05:00
commit 3bf8f1afb7
5 changed files with 88 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "CTFd"]
path = CTFd
url = https://github.com/CTFd/CTFd.git

1
CTFd Submodule

@ -0,0 +1 @@
Subproject commit 78b324e577360f4bea33ca4dc5bb480d6e6cf894

5
Gen-Certs.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
rm -rf ./CTFd/ssl/*
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out ./CTFd/ssl/ctfd.crt -keyout ./CTFd/ssl/ctfd.key

58
http.conf Normal file
View File

@ -0,0 +1,58 @@
worker_processes 4;
events {
worker_connections 1024;
}
http {
# Configuration containing list of application servers
upstream app_servers {
server ctfd:8000;
}
server {
# Unable to find a host match, enter here
listen 80 default_server;
return 444; # Malformed request, send back nginx custom return code
}
server {
listen 8443 ssl;
client_max_body_size 4G;
ssl_certificate /etc/ssl/ctfd.crt;
ssl_certificate_key /etc/ssl/ctfd.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Handle Server Sent Events for Notifications
location /events {
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 $host;
}
# 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 $host;
}
}
# Redirect all HTTP requests to HTTPS
server {
listen 80;
return 301 https://$hostname$request_uri;
}
}

21
task.md Normal file
View File

@ -0,0 +1,21 @@
# Project
Get the latest version of CTFD to work with a self-signed SSL cert with url https://sachackctf.cisnet
## Requirements
- VMWare hardware version 13 max
- [Ubuntu 20 server](https://releases.ubuntu.com/20.04/ )
- [CTFd 3.4.0](https://github.com/CTFd/CTFd)
## Deliverables
Which configurations need modifications, scripting, and other setup to permit SSL to work with CTFd 3.4.0
## Additional Notes
- Old configuration worked on ctfd 1.X, but 3.x changed the underlying framework and configuration files and our original configs no longer worked.
- Poor documentation on how to setup SSL with ctfd.io
## Task Notes
- Using Docker version 20.10.8, build 3967b7d
- NGINX Proxy is configured to run over the gunicorn worker for flask
- Nginx configuration significantly modified as well as the docker-compose.yml to permit SSL
- A script has been added "Gen-Certs.sh" that generates required self-signed keys for SSL