Sign inSign up

qubestash/nginx

By qubestash

•Updated about 9 years ago

Image
1

2.5K

qubestash/nginx repository overview

⁠QubeStash / Nginx

TravisCI Status Widget Coverage Status Widget

Based on official docker nginx⁠ image. Please read full documentation before running this image.

Default image was extended to implement automation in ssl certificate creation by using letsencrypt⁠/certbot⁠.

⁠Supported tags

  • 1.13.3, 1.13, 1, latest (run make build-latest) (Dockerfile⁠)
  • 1.13.3-alpine, 1.13-alpine, 1-alpine, alpine (run make build-alpine) (Dockerfile⁠)

Alpine is still not fixed. Use Debian based.

⁠Running a simple file server
docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d qubestash/nginx
⁠Running with a different config file
docker run --name some-nginx -v /some/nginx.conf:/etc/nginx/nginx.conf:ro -d qubestash/nginx

⁠Additional Environment Variables

⁠NGINX_CERTBOT_OPTIONS

Default value: --agree-tos

Will allow adding certbot⁠ options when generating new cerficates. This option can be used, for example, for staging environments⁠.

⁠NGINX_CERTBOT_EMAIL

Default value: [email protected]

Will allow setting a default email address to assign to all certificates generated using letsencrypt⁠.

⁠Additional Volumes

docker run --name some-nginx \
    -v /some/letsencrypt:/etc/letsencrypt \
    -v /some/nginx/conf.d:/etc/nginx/conf.d \
    -v /some/nginx/ssl:/etc/nginx/ssl \
    -v /some/qubestash:/var/qubestash \
    -d qubestash/nginx
⁠/etc/letsencrypt

Folder to mount for reaching letsencrypt⁠'s ssl certificates.

⁠/etc/nginx

Folder to mount for reaching nginx's configuration files/folders. You could either mount each config file/folder separately or mount the entire folder as a block.

⁠/var/qubestash

This is a common folder used to store various information and share them between different QubeStash⁠ projects.

In this case, it will store hashes generate for the letsencrypt⁠ generated certificates, so that certbot⁠ won't generate the certificates at every container restart.

⁠SSL Configurations

⁠Using Certbot

When using certbot⁠ (letsencrypt⁠) for generating SSL Certificates ...

server {                                                                               
    listen       80;                                                                   
    server_name local.foo subdomain.local.foo;
                                                                                       
    return 301 https://$host$request_uri;                                              
}                                                                                      
                                                                                       
server {                                                                               
    listen 443 ssl;                                                                    
    server_name local.foo subdomain.local.foo;
    ssl_certificate /etc/letsencrypt;                    
    ssl_certificate_key /etc/letsencrypt;             
                                                                                       
    location / {                                                                       
        root   /usr/share/nginx/html;                                                  
        index  index.html index.htm;                                                   
    } 

    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
⁠Using Certbot Limitations

Before attempting to run Nginx with Certbot certificate generation, please remember to read Letsencrypt's Rate Limits⁠ and Staging Environment⁠ articles.

Please note it is forbidden to create nginx host configs using multiple domain names in the same file. If, for example, you will need to mount a website/applicaiton on two different domains, when using certbot, you will need to create a config file for each domain.

The rule above does not apply for several subdomains of the same domain.

i.e.

# for local1.foo

server {                                                                               
    listen       80;                                                                   
    server_name local1.foo subdomain.local1.foo;                                                                                       
    return 301 https://$host$request_uri;     
#...                                             
}                                                                                      
                                                                                       
server {                                                                               
    listen 443 ssl;                                                                    
    server_name local1.foo subdomain.local1.foo;
    ssl_certificate /etc/letsencrypt;                    
    ssl_certificate_key /etc/letsencrypt;             
# ...
}
# for local2.foo

server {                                                                               
    listen       80;                                                                   
    server_name local2.foo subdomain.local2.foo;                                                                                       
    return 301 https://$host$request_uri;     
#...                                             
}                                                                                      
                                                                                       
server {                                                                               
    listen 443 ssl;                                                                    
    server_name local2.foo subdomain.local2.foo;
    ssl_certificate /etc/letsencrypt;                    
    ssl_certificate_key /etc/letsencrypt;             
# ...
}

both domain poiting to the same website/application.

⁠Using 3rd party SSL Certificates

When usign 3rd party SSL Certificates, place all certificates in a specific folder and mount it to /etc/nginx/ssl docker folder.

docker run --name some-nginx -v /some/nginx/ssl-certs:/etc/nginx/ssl:ro -d qubestash/nginx

Than reffer all configs that use those certificates to that folder:

# ...
server {                                                                               
    listen 443 ssl;
    server_name local.foo subdomain.local.foo;
    ssl_certificate /etc/nginx/ssl/local.fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/local.privkey.pem;
# ...
}

Tag summary

Content type

Image

Digest

Size

55.7 MB

Last updated

about 9 years ago

docker pull qubestash/nginx