Nov 5, 2017

Microservices: Running a webserver (caddy) on Ubuntu Core with snap

After the installation of a ubuntu core system inside virutalbox i was keen how to put a microservice via snap package onto the server.

First a listing of the installed snap packages:
~$ snap list
Name          Version     Rev  Developer  Notes
core          16.04.1     394  canonical  -
pc            16.04-0.8   9    canonical  -
pc-kernel     4.4.0-45-4  37   canonical  -
To get a list of available packages you can use "snap find" + a search value:
$ snap find http
Name                          Version            Developer       Notes  Summary
http                          0.9.9-1            chipaca         -      HTTPie in a snap
httpstat                      1.1.3              simosx          -      Curl statistics made simple
gost                          2.4                ginuerzh        -      GO Simple Tunnel
spreed-webrtc-snap            0.24.11-4          garywzl77       -      WebRTC audio/video calls and conferences
squid-gary                    0.3                garywzl77       -      Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more.
littlewatcher                 0.9.9              littlewatcher   -      Client for a distributed monitoring network
tinyproxy-snap                0.2                garywzl77       -      a light-weight HTTP(S) proxy daemon for POSIX operating systems.
caddy-hduran                  0.9.3              hduran          -      The HTTP/2 web server with automatic HTTPS
demo-curl                     7.47.0-1ubuntu2.1  woodrow         -      command line tool for transferring data with URL syntax
conn-check                    1.3.2-2            1stvamp         -      Utility for verifying connectivity between services
reqcounter                    0.1                meehow          -      HTTP requests counter
bhttp                         0                  rog             -      Macaroon-aware HTTP command line client
unixhttp                      1                  teknoraver      -      HTTP over Unix
wuzz                          dd696dc-1          nhandler        -      interactive cli tool for HTTP inspection
prometheus-blackbox-exporter  0.5.0              jacek           -      The Prometheus Blackbox Exporter
gnocchi                       4.0.3              james-page      -      Time Series Database as a Service
kurly                         master             carla-sella     -      kurly is an alternative to the widely popular curl program.
inadyn                        0.1                snapcrafters    -      Internet Automated Dynamic DNS Client
ipfs                          v0.4.11            elopio          -      global, versioned, peer-to-peer filesystem
tinyproxy-ogra                1.8.3              ogra            -      very tiny proxy server
demo-wget                     1.17.1-2           woodrow         -      retrieves files from the web
links                         2.12-1             zygoon          -      Web browser running in text mode
couchdb                       2.0                apache-couchdb  -      RESTful document oriented database
attfeeder                     0.0.1              sphengineering  -      Attitude angles feeder
I chose caddy-hduran:
snap install caddy-hduran 
and some seconds later the installation was finished.

The deployment structure can be found with this command:
~$ mount | grep caddy
/var/lib/snapd/snaps/caddy-hduran_12.snap on /snap/caddy-hduran/12 type squashfs (ro,relatime)
/var/lib/snapd/snaps/caddy-hduran_12.snap on /writable/system-data/snap/caddy-hduran/12 type squashfs (ro,relatime)
nsfs on /run/snapd/ns/caddy-hduran.mnt type nsfs (rw)
Twice a readonly filesystem. So where to put the configuration file?

I found
and put there a Caddyfile with this content:
tls off 
and a simple index.html. This only works with sudo.
Then i started the caddy server
/var/snap/caddy-hduran/12# caddy-hduran.caddy
Activating privacy features... done.
WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with "ulimit -n 8192".
A strange behaviour is that it will not run if you stay in
but in
it starts...

If you want more information about how to configure caddy, take a look at this blog:

Other posts around this topic: Snapcraft / Snap on ubuntu core

  • Installing Ubuntu Core on Virtualbox
  • Creating a snap containing only a shell script
  • Running a webserver (caddy) with snap

  • No comments:

    Post a Comment