Small docker image with HTTPS server based on Alpine linux.
Uses Nginx - proper server (reverse-proxy) with a self-signed certificate. The cert wouldn’t be trusted in browsers, but the communication is encrypted and great for many debugging situations.
When this Docker image is launched, a new key and certificate are generated before Nginx starts automatically.
This image was inspired by great Docker for Pentesters article.
To serve files from your current directory with https server run:
$ docker run --rm -it -p 80:80 -p 443:443 -v "${PWD}:/srv/data" dhlavaty/httpshere
...and now you can browse the contents of your dir with a browser
Use httpshere
alias (in your zsh.rc
for example):
alias httpshere='docker run --rm -it -p 80:80 -p 443:443 -v "${PWD}:/srv/data" dhlavaty/httpshere'
And now it couldn't be simpler:
$ cd /Users/myname/subdir
$ httpshere
# done
You not always need proper https server. Many times simple http static server does the job perfectly. And you even don't need Docker at all. Here are different options you may use:
# With Node.js and npm installed, use
$ npx http-server
# or
$ npx serve
# If you have Python 2
$ python -m SimpleHTTPServer 8080
# For Pyhton 3
$ python -m http.server 8080
# PHP
$ php -S localhost:8080
# With Ruby 1.9.2+
$ ruby -run -e httpd
Build multi-arch image:
$ docker buildx create --name mybuilder
$ docker buildx use mybuilder
# (Optional) check your builder
$ docker buildx inspect
$ docker buildx build --platform linux/amd64,linux/arm64 --tag dhlavaty/httpshere . --push
# (Optional) Inspect your image
$ docker buildx imagetools inspect dhlavaty/httpshere
Lint dockerfile:
$ docker run --rm -i hadolint/hadolint < Dockerfile
This project is licensed under MIT - http://opensource.org/licenses/MIT