将示例 springboot 应用程序 (WebGoat) 部署到 Azure 应用程序服务

时间:2021-05-13 13:34:26

标签: spring-boot azure azure-web-app-service spring-boot-maven-plugin azure-java-tools

Azure 应用服务的新手,遵循 https://docs.microsoft.com/en-us/azure/app-service/quickstart-java?tabs=javase&pivots=platform-linux,我尝试尝试将 WebGoat 部署到 Azure 应用,但未成功。

git clone https://github.com/WebGoat/WebGoat
cd WebGoat
git checkout v8.0.0.M26
mvn install -T 4 -Dmaven.test.skip=true -DskipTests
cd webgoat-server

//here I could deploy the jar locally with 
//$java -jar target/webgoat-server-v8.0.0.M26.jar
//and see the site at localhost:8080/WebGoat

//now trying to deploy to azure using Azure maven plguin
mvn com.microsoft.azure:azure-webapp-maven-plugin:1.14.0:config
vim pom.xml //as per below
mvn package azure-webapp:deploy

我的 webgoat-server/pom.xml

     <plugin>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-webapp-maven-plugin</artifactId>
        <version>1.14.0</version>
        <configuration>
          <schemaVersion>v2</schemaVersion>
          <subscriptionId>0665bd88-599e-4153-887a-2c51c3e094d0</subscriptionId>
          <resourceGroup>webgoat-server-1620910221297-rg</resourceGroup>
          <appName>webgoat-server-1620910221297</appName>
          <pricingTier>F1</pricingTier>
          <region>westeurope</region>
          <runtime>
            <os>Linux</os>
            <javaVersion>Java 11</javaVersion>
            <webContainer>Java SE</webContainer>
          </runtime>
          <deployment>
            <resources>
              <resource>
                <directory>${project.basedir}/target</directory>
                <includes>
                  <include>webgoat-server-v8.0.0.M26.jar</include>
                </includes>
              </resource>
            </resources>
          </deployment>
        </configuration>

我从 azure 应用服务中得到的东西 |日志流,

2021-05-13T13:03:30.937769935Z: [INFO]  2021-05-13 13:03:30.937  INFO 124 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-05-13T13:03:33.564912852Z: [INFO]  2021-05-13 13:03:33.564  INFO 124 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2021-05-13T13:03:34.138847510Z: [INFO]  2021-05-13 13:03:34.138  INFO 124 --- [           main] io.undertow                              : starting server: Undertow - 2.0.27.Final
2021-05-13T13:03:34.205034948Z: [INFO]  2021-05-13 13:03:34.204  INFO 124 --- [           main] org.xnio                                 : XNIO version 3.3.8.Final
2021-05-13T13:03:34.295912450Z: [INFO]  2021-05-13 13:03:34.295  INFO 124 --- [           main] org.xnio.nio                             : XNIO NIO Implementation Version 3.3.8.Final
2021-05-13T13:03:34.383176472Z: [ERROR]  WARNING: An illegal reflective access operation has occurred
2021-05-13T13:03:34.383264172Z: [ERROR]  WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (jar:file:/local/site/wwwroot/app.jar!/BOOT-INF/lib/xnio-nio-3.3.8.Final.jar!/) to constructor sun.nio.ch.EPollSelectorProvider()
2021-05-13T13:03:34.383276972Z: [ERROR]  WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
2021-05-13T13:03:34.383281572Z: [ERROR]  WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2021-05-13T13:03:34.384696864Z: [ERROR]  WARNING: All illegal access operations will be denied in a future release
2021-05-13T13:03:36.058791199Z: [INFO]  2021-05-13 13:03:36.058  INFO 124 --- [           main] o.s.b.w.e.u.UndertowServletWebServer     : Undertow started on port(s) 80 (http) with context path '/WebGoat'
2021-05-13T13:03:36.159459348Z: [INFO]  2021-05-13 13:03:36.158  INFO 124 --- [           main] org.owasp.webgoat.StartWebGoat           : Started StartWebGoat in 90.144 seconds (JVM running for 106.368)
2021-05-13T13:05:29  No new trace in the past 1 min(s).
2021-05-13T13:06:29  No new trace in the past 2 min(s).
2021-05-13T13:07:29  No new trace in the past 3 min(s).

来自浏览器,

导航到https://webgoat-server-1620910221297.azurewebsites.net/

502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

导航到https://webgoat-server-1620910221297.azurewebsites.net/WebGoat

:( Application Error
If you are the application administrator, you can access the diagnostic resources.

是否需要任何其他步骤来公开端口 8080 和路径 /WebGoat?

1 个答案:

答案 0 :(得分:0)

要在应用服务上公开端口 8080,请参阅 this thread

至于您应该在 site/home/wwwroot 下安装应用程序的路径。检查配置 -> 路径映射以查看虚拟目录。