/nomadic-fileserver

Provisioning an HTTP Fileserver with Hashicorp Nomad

Primary LanguageHCL

Provisioning an HTTP Fileserver

Spin up an NGINX container with Hashicorp Nomad that servers your files via HTTP. You will have to change the server_name to your domain or local IP. Run the job file and navigate your browser to port 8888:

server {
    listen 8080;
    listen [::]:8080;

    server_name  my.domain.com;

    location ~ /secret/.* {
	auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/conf.d/.htpasswd; 
        root   /usr/share/nginx/html;
    }

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

Nomad will create a text file in both the /secret/ and /public/ directory for testing:

Provisioning an HTTP Fileserver with Hashicorp Nomad

NGINX Server Configuration

Check nginx_docker_ingress on how to configure NGINX. The configuration is automatically generated by Nomad - but I did remove the TLS configuration for this example.

Service Check

The uses Consul to verify that the web service is available - if you don't use either remove the check or switch the provider to nomad:

check {
    name     = "HTTP Health"
    path     = "/"
    type     = "http"
    protocol = "http"
    interval = "10s"
    timeout  = "2s"
}