Public | Automated Build

Last pushed: 25 days ago
Short Description
nginx with auto ssl
Full Description

Pushtospace/nginx

This docker image is build with openresty to provide auto-ssl certificates.

Mounts

/web/content:/var/www/html

/conf/nginx.conf:/etc/nginx/nginx.conf

Links

redis - storage for ssl-certificates (optional)

php - compute engine (optional)

Example config

error_log /dev/stdout debug;
daemon off;

events {    
    worker_connections      1024;
}

http {

    access_log /dev/stdout;

    lua_shared_dict auto_ssl 1m;
    lua_shared_dict auto_ssl_settings 64k;
    resolver 8.8.8.8;

    init_by_lua_block {
      auto_ssl = (require "resty.auto-ssl").new()
      auto_ssl:set("allow_domain", function(domain)
        return true
      end)
      auto_ssl:set("storage_adapter", "resty.auto-ssl.storage_adapters.redis")
      auto_ssl:set("redis", {
        host = "redis",
        port = 6379
      })
      auto_ssl:init()
    }

    init_worker_by_lua_block {
      auto_ssl:init_worker()
    }

    sendfile                on;
    tcp_nopush              on;
    tcp_nodelay             on;
    keepalive_timeout       65;
    types_hash_max_size     2048;

    include                 /etc/nginx/mime.types;
    default_type            application/octet-stream;

    server {
      listen 127.0.0.1:8999;
      client_body_buffer_size 128k;
      client_max_body_size 128k;
      location / {
        content_by_lua_block {
          auto_ssl:hook_server()
        }
      }
    }

    server {
        listen              80;
        server_name         servername.com www.servername.com;

        location /.well-known/acme-challenge/ {
          content_by_lua_block {
            auto_ssl:challenge_server()
          }
        }

        return 301 https://$server_name$request_uri;
    }

    server {
        listen              443 ssl;

        ssl_certificate_by_lua_block {
            auto_ssl:ssl_certificate()
        }

        server_name         servername.com www.servername.com;
        root                /var/www/html/;
        ssl_certificate     /etc/ssl/resty-auto-ssl-fallback.crt;
        ssl_certificate_key /etc/ssl/resty-auto-ssl-fallback.key;

        location / {
            try_files       $uri /index.html =404;
        }

    }
}
Docker Pull Command
Owner
pushtospace
Source Repository

Comments (0)