From 5ec5a3e64ee40d4285dd33621925821d4dc253ed Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:49:33 +0200 Subject: [PATCH] localhost nginx --- nginx/nginx.local.conf | 26 ++++++++++++++++++++++++++ nginx/run.sh | 21 ++++++++++++++++----- 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 nginx/nginx.local.conf diff --git a/nginx/nginx.local.conf b/nginx/nginx.local.conf new file mode 100644 index 0000000..236b74e --- /dev/null +++ b/nginx/nginx.local.conf @@ -0,0 +1,26 @@ +events { + worker_connections 512; +} + +http { + server { + listen 80; + + server_name "nilstrieb.dev"; + + return 302 http://blog.nilstrieb.dev$request_uri; + } + + server { + listen 80; + + server_name "private-docker-registry.nilstrieb.dev"; + + location / { + return 404 'No registry here...'; + #proxy_pass http://registry:5000/; + } + } + + server_tokens off; +} \ No newline at end of file diff --git a/nginx/run.sh b/nginx/run.sh index 0717c69..fca53f5 100755 --- a/nginx/run.sh +++ b/nginx/run.sh @@ -2,13 +2,24 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +if [ $STAGE = "localhost" ] ; +then + echo "INFO Running on localhost" + NGINX_CONF="nginx.local.conf" + CERT_VOLUME="" +else + echo "INFO Running on prod" + NGINX_CONF="nginx.conf" + CERT_VOLUME="-v=/etc/letsencrypt:/etc/nginx/certs" +fi + if docker container inspect nginx > /dev/null 2>&1 ; then - echo "nginx container exists already..." + echo "INFO nginx container exists already..." else - docker run -d -p 80:80 -p 443:443 --restart=always --name nginx \ - -v "$SCRIPT_DIR/nginx.conf:/etc/nginx/nginx.conf:ro" \ - -v "/etc/letsencrypt:/etc/nginx/certs" \ - --net internal \ + docker run -d -p 80:80 -p 443:443 --restart=always --name=nginx \ + -v="$SCRIPT_DIR/$NGINX_CONF:/etc/nginx/nginx.conf:ro" \ + $CERT_VOLUME \ + --net=internal \ nginx:latest fi \ No newline at end of file