Sign inSign up

travix/nginx

By travix

•Updated over 7 years ago

NGinx reverse proxy

Image
2

1M+

travix/nginx repository overview

⁠Usage

To run this docker container use the following command

docker run -d travix/nginx:latest

⁠Environment variables

In order to configure the nginx load balancer for providing ssl on port 443 for your gocd server you can use the following environment variables

NameDescriptionDefault value
BACKEND_SERVERThe ip address of the gocd serverlocalhost
BACKEND_SERVER_PORTThe http port the gocd server listens to80
WHITELIST_CIDRSSpace separated list of IPs to be whitelisted

To run nginx to redirect to ssl and provide access through normal https port (443) to gocd server run the following command

docker run -d \
    -e "BACKEND_SERVER=origin.yourdomain.com" \
    -e "BACKEND_SERVER_PORT=8153" \
    travix/nginx:latest

⁠Restricting access

To allow access from a certain set of addresses, run the container with the following environment variable

docker run -d \
    -e "BACKEND_SERVER=origin.yourdomain.com" \
    -e "BACKEND_SERVER_PORT=8153" \
    -e "WHITELIST_CIDRS=1.2.3.4/32 9.8.7.6" \
    travix/nginx:latest

⁠Mounting volumes

In order to keep your ssl certificate outside of the container on the host machine you can mount the following directories

DirectoryDescriptionImportance
/etc/nginxConfiguration for nginxIf configuration needs to be different from the one in the container
/etc/ssl/certsCA certificatesKeep these files safe
/etc/ssl/private/SSL certificatesKeep these files safe

Start the container like this to mount the directories

docker run -d \
    -e "BACKEND_SERVER=origin.yourdomain.com" \
    -e "BACKEND_SERVER_PORT=8153" \
    -v /mnt/persistent-disk/nginx/config:/etc/nginx
    -v /mnt/persistent-disk/nginx/ssl:/etc/ssl/private
    travix/nginx:latest

To make sure the process in the container can read and write to those directories create a user and group with same gid and uid on the host machine

groupadd -r -g 999 nginx
useradd -r -g nginx -u 999 nginx

And then change the owner of the host directories

chown -R nginx:nginx /mnt/persistent-disk/nginx/config
chown -R nginx:nginx /mnt/persistent-disk/nginx/ssl

Tag summary

Content type

Image

Digest

Size

2.8 MB

Last updated

over 9 years ago

docker pull travix/nginx