Skip to content

Docker image for nginx (supports Brotli, GeoIP2, TLS 1.3, etc.)

License

Notifications You must be signed in to change notification settings

bohanyang/docker-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker image for NGINX

Info

Usage

Put your config files (nginx.conf etc.) inside a folder, for example: ~/nginx-config.

Then run the container:

docker run --name nginx --net host --restart always -v "$HOME/nginx-config:/var/nginx/conf:ro" -d bohan/nginx

Note that you must mount the config dir to this specific /var/nginx/conf path!

Your config files will replace the default config files.

Reload Configuration Without Downtime

You can even change your configuration after the container start and apply them without any downtime.

After change, run the command:

docker exec nginx nginx-reload

This nginx-reload script will test your new configuration and reload the server. It will rollback if the test fails.

Load Dynamic Modules

Add these in the top‑level (main) context of your nginx.conf configuration file (not within the http or stream context):

load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so;
load_module /usr/lib/nginx/modules/ngx_http_brotli_static_module.so;
load_module /usr/lib/nginx/modules/ngx_http_geoip2_module.so;

Logs

We used to redirect the default paths for log (/var/log/nginx/access.log and /var/log/nginx/error.log) to stdout and stderr respectively, but now they are left untouched.

Instead, we encourage you to configure nginx to use the built-in s6-log service for automatic rotation and other features.

In your configuration, just set the access_log and error_log paths to /var/run/s6/nginx-access-log-fifo and /var/run/s6/nginx-error-log-fifo respectively.

error_log /var/run/s6/nginx-error-log-fifo warn;

http {

    access_log /var/run/s6/nginx-access-log-fifo combined;

    # other configuration...
}

After reload or restart, you'll find the logs inside /var/log/nginx-access-log and /var/log/nginx-error-log directories.

About

Docker image for nginx (supports Brotli, GeoIP2, TLS 1.3, etc.)

Resources

License

Stars

Watchers

Forks

Packages