How can I perform a simple NGINX Test with Docker Compose

How can I perform a simple NGINX Test with Docker Compose

This guide will help you set up a simple NGINX web server using Docker with HTTPS support on a Yale SpinUp server.

For Ubuntu 22.04 - CIS ensure you enable ports 80 and 443 via nftables: How Do I Use nftables in Linux?

Yale SpinUp Server Setup

1. Get the Repository Files

Clone the repository to your SpinUp server:

git clone https://git.yale.edu/tsh46/simple-nginx-test.git cd simple-nginx-test

The repository contains all the necessary files:

  • docker-compose.yml

  • nginx.conf

  • index.html

2. Update Server Name

Edit nginx.conf and change the server name to your SpinUp domain:

server_name spinup-002bc2.spinup.yale.edu;

Change this in both server blocks (HTTP and HTTPS sections).

3. Create SSL Certificate

Run this command in the project directory:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./key.pem -out ./cert.pem

When prompted for Common Name, enter your SpinUp domain (e.g., spinup-002bc2.spinup.yale.edu).

4. Start the Server

docker-compose up -d

Troubleshooting

  • Certificate Error in Browser: This is normal with self-signed certificates. Click "Advanced" and proceed anyway.

  • Port Conflicts: If ports 80/443 are already in use, change the port mapping in docker-compose.yml

  • Missing Certificate: Make sure key.pem and cert.pem are in the same folder as the other files