- Getting the image
- Run the bare image
- Configuration
- Proxy server
- Match request path with regex
- Load balancing
docker pull nginx
docker run --rm -d -p 80:80 nginx
curl localhost
You should get the Welcome to nginx web page.
Configuration directives's hierachy:
main
context containsevents
andhttp
http
containsserver
server
containslocation
Loading a minimal configuration (see ./nginx.conf
for details):
docker run --rm -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro -v $(pwd)/data:/data:ro -p80:80 nginx
Then you should be able to get:
See nginx-proxy.conf
.
docker run --rm -v $(pwd)/nginx-proxy.conf:/etc/nginx/nginx.conf:ro -v $(pwd)/data:/data:ro -p80:80 nginx
curl localhost
See nginx-regex.conf
.
docker run --rm -v $(pwd)/nginx-regex.conf:/etc/nginx/nginx.conf:ro -v $(pwd)/data:/data:ro -p80:80 nginx
See nginx-lb.conf
.
docker run --rm -d -v $(pwd)/nginx-lb.conf:/etc/nginx/nginx.conf:ro -v $(pwd)/data:/data:ro -p 80:80 nginx
Now if you keep reading from http://localhost, it will respond with these responses in round-robin order:
- hello from site 1
- hello from site 2
- hello from site 3