This repo contains the necessary files to create a reverse proxy using Nginx in a Docker environment. The reverse proxy enables routing of HTTPS connections and utilizes Let's Encrypt certificates to ensure security.
The repository includes the following files:
docker-compose.yml: The Docker Compose configuration file that defines the services and networks for the Nginx container.Dockerfile: The Dockerfile used to build the Nginx container image, with Certbot installed.text.conf: A sample Nginx configuration file that sets up a reverse proxy tohttps://google.comand includes some proxy headers.
Before using this repository, ensure that you have Docker and Docker Compose installed on your system.
npx degit dariasmyr/nginx-proxy my-app
To configure the Nginx container with HTTPS support for your specific host, follow these steps:
-
Create a
.certfile for your host, using the example provided intext.conf. Modify theserver_namedirective to match your host. -
Start the Docker container by running the following command:
docker-compose up -d
-
Open a terminal inside the running container:
docker-compose exec -it nginx bash -
Once inside the container, run the Certbot command to obtain an SSL certificate:
certbot --nginx
-
Follow the Certbot prompts to select the appropriate .conf file containing your host configuration.
-
Certbot will automatically configure Nginx with the obtained SSL certificate and update the Nginx configuration.
-
Restart the Nginx container to apply the changes:
docker-compose restart nginx
Feel free to modify the text.conf file according to your specific reverse proxy requirements. You can add or modify the proxy headers, change the target URL, or configure additional locations.
For more information on using Nginx and Certbot, refer to the following documentation:
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.