diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 000000000..d392f0e82 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1 @@ +*.jar diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..39027d357 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,30 @@ +FROM openjdk:11.0.1-jre-slim-stretch + +ARG webgoat_version=v8.0.0-SNAPSHOT +ENV webgoat_version_env=${webgoat_version} + +RUN apt-get update && apt-get install +RUN useradd --home-dir /home/webgoat --create-home -U webgoat +RUN apt-get -y install apt-utils nginx + +USER webgoat +RUN cd /home/webgoat/; mkdir -p .webgoat-${webgoat_version} + +COPY nginx.conf /etc/nginx/nginx.conf +COPY index.html /usr/share/nginx/html/ +COPY webgoat-server-${webgoat_version}.jar /home/webgoat/webgoat.jar +COPY webwolf-${webgoat_version}.jar /home/webgoat/webwolf.jar +COPY start.sh /home/webgoat + +EXPOSE 8080 +EXPOSE 9090 + +ENV WEBGOAT_PORT 8080 +ENV WEBGOAT_SSLENABLED false + +ENV GOATURL https://127.0.0.1:$WEBGOAT_PORT +ENV WOLFURL http://127.0.0.1:9090 + + +WORKDIR /home/webgoat +ENTRYPOINT /bin/bash /home/webgoat/start.sh $webgoat_version_env diff --git a/docker/Readme.md b/docker/Readme.md new file mode 100644 index 000000000..84a2921ed --- /dev/null +++ b/docker/Readme.md @@ -0,0 +1,9 @@ +# Docker all-in-one image + +## Docker build + + docker build --no-cache --build-arg webgoat_version=v8.0.0-SNAPSHOT -t webgoat/goatandwolf:latest . + +## Docker run + + docker run -d -p 80:8888 -p 8080:8080 -p 9090:9090 -e TZ=Europe/Amsterdam webgoat/goatandwolf:latest \ No newline at end of file diff --git a/docker/index.html b/docker/index.html new file mode 100644 index 000000000..b0649f67b --- /dev/null +++ b/docker/index.html @@ -0,0 +1,43 @@ + + + +

OWASP WebGoat Training tools

+

+ Use the following links to access the WebGoat and WebWolf applications. + Register a user using WebGoat. The same user can access WebWolf. +

+ +

Use without special host name entries

+ + + + + + + + + + +
WebGoat URLhttp://127.0.0.1:8080/WebGoat
WebWolf URLhttp://127.0.0.1:9090/WebWolf
+ +

Use with www.webgoat.local and www.webwolf.local

+

+ Add the following entries to your local hosts file on Windows (c:\Windows\System32\drivers\etc\hosts) or Linux (/etc/hosts) + +

+127.0.0.1 www.webgoat.local www.webwolf.local
+
+ Then use the following URL's: +

+
+ + + + + + + + +
WebGoat URLhttp://www.webgoat.local/WebGoat
WebWolf URLhttp://www.webwolf.local/WebWolf
+ + diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 000000000..1ca404260 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,140 @@ +error_log /tmp/error.log; +pid /tmp/nginx.pid; + +worker_processes 1; + +events { worker_connections 1024; } + +http { + + client_body_temp_path /tmp/client_body; + fastcgi_temp_path /tmp/fastcgi_temp; + proxy_temp_path /tmp/proxy_temp; + scgi_temp_path /tmp/scgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + + sendfile on; + + upstream docker-webgoat { + server 127.0.0.1:8080; + } + + upstream docker-webwolf { + server 127.0.0.1:9090; + } + + 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-Host $server_name; + + server { + listen 8888; + server_name www.webgoat.local; + + root /var/www; + + access_log /tmp/goataccess.log; + error_log /tmp/goaterror.log; + + location ~* \.(png|jpg|jpeg|gif|ico|woff|otf|ttf|mvc|svg|txt|pdf|docx?|xlsx?)$ { + access_log off; + proxy_pass http://docker-webgoat; + proxy_redirect off; + } + + location / { + root /usr/share/nginx/html; + index index.html; + add_header Cache-Control no-cache; + expires 0; + } + + location /WebGoat { + proxy_pass http://docker-webgoat; + proxy_redirect off; + } + + } + + server { + listen 8888; + server_name www.webwolf.local; + + root /var/www; + + access_log /tmp/wolfaccess.log; + error_log /tmp/wolferror.log; + + location /WebGoat/PasswordReset/ForgotPassword/create-password-reset-link { + proxy_pass http://docker-webgoat; + proxy_redirect off; + } + + location /PasswordReset/reset/reset-password { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /files { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /tmpdir { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /webjars { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /css { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /login { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /images { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /mail { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /upload { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /js { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /landing { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /logout { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + location /WebWolf { + proxy_pass http://docker-webwolf; + proxy_redirect off; + } + + } +} diff --git a/docker/pom.xml b/docker/pom.xml new file mode 100644 index 000000000..6c588c39a --- /dev/null +++ b/docker/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + webgoat-all-in-one-docker + jar + + org.owasp.webgoat + webgoat-parent + v8.0.0-SNAPSHOT + + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + install + + + + + + + + run + + + + + + + + diff --git a/docker/start.sh b/docker/start.sh new file mode 100644 index 000000000..e14452e26 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +cd /home/webgoat +service nginx start +sleep 1 +java -Dfile.encoding=UTF-8 -jar webgoat.jar --webgoat.build.version=$1 --server.address=0.0.0.0 > webgoat.log & + +sleep 10 + +java -Dfile.encoding=UTF-8 -jar webwolf.jar --webgoat.build.version=$1 --server.address=0.0.0.0 > webwolf.log & + +tail -300f webgoat.log diff --git a/pom.xml b/pom.xml index 18878dfe8..550a2f934 100644 --- a/pom.xml +++ b/pom.xml @@ -144,6 +144,7 @@ webgoat-serverwebwolfwebgoat-integration-tests + docker diff --git a/scripts/deploy-webgoat.sh b/scripts/deploy-webgoat.sh index 4115a90e8..ce2517255 100644 --- a/scripts/deploy-webgoat.sh +++ b/scripts/deploy-webgoat.sh @@ -33,4 +33,17 @@ if [ ! -z "${TRAVIS_TAG}" ]; then docker push $REPO else echo "Skipping releasing to DockerHub because it is a build of branch ${BRANCH}" -fi \ No newline at end of file +fi + +export REPO=webgoat/goatandwolf +cd .. +cd docker +ls target/ + +if [ ! -z "${TRAVIS_TAG}" ]; then + # If we push a tag to master this will update the LATEST Docker image and tag with the version number + docker build --build-arg webgoat_version=${TRAVIS_TAG:1} -f Dockerfile -t $REPO:latest -t $REPO:${TRAVIS_TAG} . + docker push $REPO +else + echo "Skipping releasing to DockerHub because it is a build of branch ${BRANCH}" +fi