├── Dockerfile ├── Makefile ├── .gitignore ├── README.md ├── LICENSE └── service.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Kentaro Imajo 3 | RUN apt-get update -qq && apt-get -y install sslh 4 | CMD sslh -f -u root -p 0.0.0.0:443 --ssh 172.17.42.1:22 --ssl 172.17.42.1:10443 5 | EXPOSE 443 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | bash service.sh start 3 | .PHONY: start 4 | 5 | stop: 6 | bash service.sh stop 7 | .PHONY: stop 8 | 9 | install: 10 | bash service.sh install 11 | .PHONY: install 12 | 13 | uninstall: 14 | bash service.sh uninstall 15 | .PHONY: uninstall 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Compiled Dynamic libraries 8 | *.so 9 | *.dylib 10 | *.dll 11 | 12 | # Compiled Static libraries 13 | *.lai 14 | *.la 15 | *.a 16 | *.lib 17 | 18 | # Executables 19 | *.exe 20 | *.out 21 | *.app 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | sslh in Docker 2 | ============== 3 | 4 | Install sslh inside Docker. 5 | 6 | How to Install 7 | -------------- 8 | 9 | Docker must be installed beforehand. 10 | 11 | How to Run sslh 12 | --------------- 13 | 14 | Run the following command: 15 | 16 | ```sh 17 | make start 18 | ``` 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Kentaro IMAJO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /service.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : ${SERVICE:=sslh} 4 | : ${CPU:=100} 5 | : ${MEMORY:=100M} 6 | : ${DISK:=5G} 7 | : ${SSLH_PORT:=0.0.0.0:443} 8 | 9 | set -e -u 10 | 11 | if [ "$(whoami)" != 'root' ]; then 12 | echo 'this script must run as root.' >&2 13 | exit 1 14 | fi 15 | 16 | docker_build() { 17 | docker build --tag="${SERVICE}" . 18 | } 19 | 20 | docker_run() { 21 | local docker_flags=("${DOCKER_FLAGS[@]}") 22 | docker_flags+=( 23 | --memory="${MEMORY}" --cpu-shares="${CPU}" 24 | --publish="${SSLH_PORT}:443") 25 | docker run "${docker_flags[@]}" "${SERVICE}" "$@" 26 | } 27 | 28 | start() { 29 | if docker top "${SERVICE}" >/dev/null 2>/dev/null; then 30 | echo 'docker is already running.' >&2 31 | fi 32 | DOCKER_FLAGS=(--name="${SERVICE}" --hostname="${SERVICE}" --detach) 33 | docker_build 34 | docker_run "$@" 35 | } 36 | 37 | stop() { 38 | docker kill "${SERVICE}" >/dev/null || true 39 | docker rm "${SERVICE}" >/dev/null || true 40 | } 41 | 42 | install() { 43 | docker_build 44 | } 45 | 46 | command="$1" 47 | shift 48 | case "${command}" in 49 | 'start') start "$@";; 50 | 'stop') stop;; 51 | 'install') install;; 52 | 'uninstall') :;; 53 | *) echo "no such command: ${command}" >&2;; 54 | esac 55 | --------------------------------------------------------------------------------