nginx forward to https with docker
Step 1. Build nginx.conf
$ vim nginx.conf
events {
}
http {
server {
listen 80;
location / {
return 301 https://$host$request_uri;
}
}
}
Step 2. Docker run nginx
$ docker run --name nginx-container -p 80:80 -v "$(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro" -d nginx
or
% mkdir html % echo "ok" > html/health.html % docker run --name nginx-container -p 80:80 -v "$(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro" -v $(pwd)/html:/usr/share/nginx/html -d nginx