nginx simple reverse proxy
- Copy your certificates to
/etc/nginx/ssl
cp fullchain.crt /etc/nginx/ssl/fullchain.crt
cp server.key /etc/nginx/ssl/server.key
- Change the permissions to the
server.key
file
chmod 400 /etc/nginx/ssl/server.key
- Add the following compose part to your
docker-compose.yml
version: "3.7"
services:
proxy:
image: dameyerdave/nxsrp:latest
hostname: proxy
volumes:
- /etc/nginx/ssl:/etc/nginx/ssl
ports:
- "443:443"
networks:
- <docker-network>
restart: unless-stopped
environment:
- NGINX_SERVER_NAME=${NGINX_SERVER_NAME}
- BACKEND_URL=${BACKEND_URL}
networks:
<docker-network>:
- Add a
.env
file with the following content
NGINX_SERVER_NAME=my.server.domain.com
BACKEND_URL=http://<docker-hostname>:<port>
- Compose the docker
- [OR] Run it via
docker
command
docker run
--name proxy
--hostname proxy
--net <docker-network>
-e NGINX_SERVER_NAME=my.server.domain.com
-e BACKEND_URL=http://localhost:5000
-v /etc/nginx/ssl:/etc/nginx/ssl
-p 443:443
-it -d
dameyerdave/nxsrp:latest