diff --git a/conf/nginx.conf b/conf/nginx.conf index 53fdced..a9b9d4b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -15,13 +15,6 @@ http { charset utf-8; default_type text/html; - # ssl_certificate /var/www/certs/miti.sh/fullchain.pem; - # ssl_certificate_key /var/www/certs/miti.sh/privkey.pem; - - location ^~ /.well-known/acme-challenge { - alias /var/www/dehydrated; - } - try_files $uri $uri/ $uri.html =404; # return `/posts/index.html` from `/posts` @@ -41,41 +34,7 @@ http { } server { - # listen 443 ssl; - server_name git.miti.sh; - - location ^~ /.well-known/acme-challenge { - alias /var/www/dehydrated; - } - - location / { - client_max_body_size 1024M; - proxy_pass http://localhost:3000; - proxy_set_header Connection $http_connection; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - } - - server { - # listen 443 ssl; - server_name apps.miti.sh; - - root /var/www/sites/apps.miti.sh; - - include mime.types; - charset utf-8; - default_type text/html; - - location ^~ /.well-known/acme-challenge { - alias /var/www/dehydrated; - } - } - - server { + listen 8080; # listen 443 ssl; server_name webdevcat.me; @@ -83,15 +42,8 @@ http { charset utf-8; default_type text/html; - # ssl_certificate /var/www/certs/webdevcat.me/fullchain.pem; - # ssl_certificate_key /var/www/certs/webdevcat.me/privkey.pem; - - location ^~ /.well-known/acme-challenge { - alias /var/www/dehydrated; - } - location / { - return 301 https://miti.sh$request_uri; + return 301 http://miti.sh:8080$request_uri; } location ~ ^/git/(.*)$ { @@ -102,20 +54,4 @@ http { return 301 https://apps.miti.sh/$1; } } - server { - # listen 443 ssl; - server_name git.webdevcat.me; - - location ^~ /.well-known/acme-challenge { - alias /var/www/dehydrated; - } - } - server { - # listen 443 ssl; - server_name apps.webdevcat.me; - - location ^~ /.well-known/acme-challenge { - alias /var/www/dehydrated; - } - } } diff --git a/test.sh b/test.sh index e935234..35c62a2 100755 --- a/test.sh +++ b/test.sh @@ -4,14 +4,38 @@ # curl http://webdevcat.me:8080 image=miti.sh -echo "starting container..." +echo "Starting test container..." container_id=$(docker run --rm -d -v $(pwd):/opt/app -p 8080:8080 \ --add-host=miti.sh=127.0.0.1 \ --add-host=webdevcat.me=127.0.0.1 \ $image) -echo "container $container_id started" -echo "stopping container $container_id" -stop_cmd_result=$(docker stop $container_id) -echo "container $stop_cmd_result stopped" -# curl http://miti.sh:8080 +echo "Test container started" + +# docker exec -t $container_id curl http://miti.sh:8080 +# docker exec -t $container_id curl -v http://webdevcat.me:8080 + +echo "redirects webdevcat.me to miti.sh" + +response=$(docker exec -t $container_id curl -so /dev/null \ + -w "%{http_code} %{redirect_url}" http://webdevcat.me:8080) + +expected="301 http://miti.sh:8080/" + +if [[ $response != $expected ]]; then + echo "TEST FAILED" + printf "expected: $expected\ngot: $response\n" +else + echo "TEST PASSED" +fi + +echo "Stopping test container" +docker exec $container_id openresty -p /opt/app -s stop + +is_running=$(docker inspect -f '{{.State.Running}}' $container_id) + +if [[ $is_running == "true" ]]; then + echo "Warning: Docker reports test container is still running" +else + echo "Test container stopped" +fi