├── .gitignore ├── .dockerignore ├── global.conf ├── http.conf ├── Dockerfile.template ├── README.md └── Makefile /.gitignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | README.md 3 | -------------------------------------------------------------------------------- /global.conf: -------------------------------------------------------------------------------- 1 | daemon off; 2 | error_log stderr; 3 | pid /run/nginx.pid; 4 | -------------------------------------------------------------------------------- /http.conf: -------------------------------------------------------------------------------- 1 | access_log /dev/stdout; 2 | 3 | server { 4 | listen 80 default_server; 5 | listen [::]:80 default_server; 6 | server_name _; 7 | 8 | return 307 https://$host$request_uri; 9 | } 10 | -------------------------------------------------------------------------------- /Dockerfile.template: -------------------------------------------------------------------------------- 1 | # NOTE: Don't modify this file directly - see Makefile 2 | 3 | FROM alpine:{{ .AlpineVersion }} 4 | 5 | LABEL git.commithash="{{ .GitCommit }}" 6 | 7 | RUN apk --update --no-cache add nginx 8 | 9 | COPY global.conf /etc/nginx/modules/global.conf 10 | COPY http.conf /etc/nginx/conf.d/default.conf 11 | 12 | EXPOSE 80 13 | 14 | CMD /usr/sbin/nginx 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HTTP to HTTPS 2 | ============= 3 | 4 | The web is moving to TLS. This is a Docker container that forces browser 5 | redirection from HTTP to HTTPS for all hosts that hit it. 6 | 7 | HTTP code 307 is used to redirect browsers so that the HTTP method does not 8 | change (which would happen with old clients using 301/302). 9 | 10 | Running: 11 | -------- 12 | 13 | ``docker run --rm -p80:80 -d realkinetic/http-to-https:latest``. 14 | 15 | Building 16 | -------- 17 | 18 | ``make build`` 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | $(eval GIT_COMMIT = $(shell git rev-parse HEAD)) 2 | 3 | ALPINE_VERSION=3.11 4 | 5 | DOCKER_BASE=realkinetic/http-to-https 6 | DOCKER_TAG=1.2 7 | 8 | default: build 9 | 10 | clean: 11 | rm -f Dockerfile 12 | 13 | Dockerfile: Dockerfile.template 14 | sed \ 15 | -e 's!{{ .AlpineVersion }}!'"$(ALPINE_VERSION)"'!g' \ 16 | -e 's!{{ .Version }}!'"$(DOCKER_TAG)"'!g' \ 17 | -e 's!{{ .GitCommit }}!'"$(GIT_COMMIT)"'!g' \ 18 | Dockerfile.template > Dockerfile 19 | 20 | build: Dockerfile 21 | docker build -t $(DOCKER_BASE):$(DOCKER_TAG) . 22 | 23 | run: build 24 | docker run -it -p80:80 --rm $(DOCKER_BASE):$(DOCKER_TAG) 25 | 26 | debug: build 27 | docker run -it -p80:80 --rm $(DOCKER_BASE):$(DOCKER_TAG) /bin/sh 28 | 29 | push: build 30 | docker push $(DOCKER_BASE):$(DOCKER_TAG) 31 | --------------------------------------------------------------------------------