Clone the repo, edit docker-compose.yml and nginx.conf to your requirements, then docker compose up -d
I have included a sample nginx conf, for tcp connections.
Original readme ⬇⬇
Nginx compiled with --with-stream to be able to create proxies or loadbalancers for non http protocols.
This repository contains Dockerfile of Nginx Stream
-
Install Docker.
-
Download:
docker pull tekn0ir/nginx-stream
(alternatively, you can build an image from Dockerfile:
$ docker build -t="tekn0ir/nginx-stream" github.com/tekn0ir/nginx-stream
Start deamon
$ docker run -d -p 0.0.0.0:80:80 --name nginx tekn0ir/nginx-stream
Create configuration files in folders example:
.
|
|-- http.conf.d
| `-- myhttpservice.conf
|
|-- stream.conf.d
`-- myotherservice.conf
myhttpservice.conf example config:
upstream myhttpservice {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80;
location / {
proxy_pass http://myapp1;
}
}
myotherservice.conf example config:
upstream myotherservice {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 65432;
proxy_pass myotherservice;
}
For little more help on stream config: https://nginx.org/en/docs/stream/ngx_stream_core_module.html
Start deamon with configs
$ docker run -d -p 80:80 -p 65432:65432 -v `pwd`\http.conf.d:/opt/nginx/http.conf.d -v `pwd`\stream.conf.d:/opt/nginx/stream.conf.d --name nginx tekn0ir/nginx-stream
If you change settings and need to relaod them on a running container w/o downtime
$ docker exec -ti nginx bash -c 'zero_downtime_reload.sh'