A meant-for-docker, nginx-based, HTTP proxy for serving static files, forwarding requests to upstreams, as well as local development.
proxy:
image: tivix/docker-nginx:v16
ports:
- 127.0.0.1:80:80
environment:
# Point paths (<path>:<container>:<port>) to your backend containers
- UPSTREAMS=/api:backend:8000,/:frontend:80
# Point paths (<path>:<some-dir-in-docker-nginx-container>) to static files server directly by nginx
- STATICS=/static:/data/static
Some of the envrionment variables available:
MAINTENANCE=truenginx sets root to static html page; set true to activate, delete var to deactivateUPSTREAMS=/:backend:8000a comma separated list of <path>:<upstream>:<port>. Each of those of those elements creates a location block with proxy_pass in it.STATICS=/static:/data/statica comma separated list of <path>:<directory>. Creates a location block withaliasdirective.HTTPS_REDIRECT=trueenabled a standard, ELB compliant https redirect.BASIC_AUTH_ALL=trueenables a catch-all basic auth protection. Must be used in conjuction with BASIC_AUTH_USER and BASIC_AUTH_PASS (or AWS Secrets Manager, see below)BASIC_AUTH_LOCATIONS=/apienables basic auth protection for selected locations. The paths must be declared in UPSTREAMS first.AWS_SM_PATHandAWS_SM_KEYwill get the basic auth password from AWS Secrets Manager. Requires standard AWS API access, either via Instance Profile or API keys.
AWS_SM_PATH=staging
AWS_SM_KEY=NGINX_PASSWORD
AWS_DEFAULT_REGION=us-west-1
The above will get the password from AWS Secret Manager secret named staging, and extract the value of NGINX_PASSWORD from it.
LOG_LEVEL=infoallows you to set nginx error_log verbosity. Defaults tonotice.GZIP=trueenables standard GZIP compression with some sane defaultsREAL_IP=trueenables parsing of X-Forwarded-For header.REAL_IP_HEADER=X-Real-Ipcustomizes which header to use for real_ipREAL_IP_CIDRS=10.0.0.0/8,192.168.0.0/16sets the set_real_ip_from directiveMICROCACHE=trueenables "microcaching". Nginx will cache upstream responses for short ammount of time.MICROCACHE_TIMEOUThow long to cache responses for. Defaults to 1s.DEBUGmakes things verboseDEV_SSL_CERTsomewhat hacky for now. Adds assl onlisten directive with (currently) hardcoded, self-signed certificate.WORKER_PROCESSES=autonumber of nginx processes. Access the same values as worker_processes directive.UWSGI=trueswitches proxy_pass to uwsgi_passSTATS=/statscreates a stub_status endpoint at the defined path, accessible from 127.0.0.1 only.STATS_PORT=8080port the stats endpoint listens at. Defaults to 8080.HEALTHCHECK=/healthenables simple healthcheck endpoint at the defined path, accessible from 127.0.0.1 only. Think Docker healthcheck-cmdcurl -sSf 127.0.0.1:8080/healthHEALTHCHECK_PORT=8080port the healthcheck listens at. Defaults to 8080.HEALTHCHECK_LISTEN=127.0.0.1IP address the healthcheck listens on. Defaults to 127.0.0.1.NOSNIFF=trueenables X-Content-Type-Options: nosniff. Defaults tofalse.CSP=trueenables Content Security Policy. Defaults tofalse.CLEAR_SERVER_HEADERremoves theServerheader from responses. Defaults totrue.
...and some others. See the code.