docker: nginx Installing a reverse proxy / setting a DNS.
In this guide we setup a nginx reverse proxy that talks to a mysql for it's setup. It binds to port 81.
Installing the script for docker / docker-compose is located here: nginx typically binds to port 81.
docker-compose.yaml file:
version: '3'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
container_name: proxy-manager
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./config.json:/app/config/production.json
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
networks:
- nginx-proxy
volumes:
data:
letsencrypt:
networks:
nginx-proxy:
external:
name: nginx-proxy-network
And now setup your config.json. Note you can see in the following config line - that config.json in the local directory will be mapped and built into /app/config/production.json inside the container.
- ./config.json:/app/config/production.json
config.json
{
"database":
{
"engine": "mysql",
"host": "localhost:3306",
"name": "root",
"user": "root",
"password": "somepassword",
"port": 3306
}
"server":
{
"proxy_pass" : "http://107.152.41.231:8080",
"proxy_set_header" : "X-Forwarded-For $proxy_add_x_forwarded_for",
"proxy_set_header" : "X-Forwarded-Proto $scheme",
"proxy_set_header" : "X-Real-IP $remote_addr",
"proxy_set_header" : "Host $http_host",
}
}
Now you will need to get a mysql working that can accept it at this guide.
To run to make sure it works:
docker-compose up
To run in permanent daemon mode:
docker-compose up -d