【Azure 应用服务】App Service 默认页面暴露Tomcat版本信息,存在安全风险

简介: 【Azure 应用服务】App Service 默认页面暴露Tomcat版本信息,存在安全风险

问题描述

在创建Azure App Service时,服务端的配置使用Java 8 + Tomcat 8.5。默认的根目录页面显示出App Service Tomcat版本信息,存在一定的安全隐患。

如何来避免这个问题呢?

 

问题解答

因为在初始创建App Service时,Azure会根据所选Stack, Web Server的信息默认生成首页内容。大多是情况下,在部署您的应用时,默认的首页内容会被替换掉。

App Service默认使用的首页名称如下(这些文件位于wwwroot目录下):

但对于Java Tomcat服务,默认的首页启动路径为 wwwroot/webapps/ROOT/index.jsp, 所以只需要修改 index.jsp中的内容或者删除这个文件就可以避免根路径 (“/”) 泄露服务信息。

 

修改步骤

1)登录App Service Kudu站点 ( 在左侧目录栏中选择 Advanced Tools –> Go 进入Kudu站点(https://<your app service name>.scm.chinacloudsites.cn/)), 选择 Debug Console 页面

2)  进入 HOME\SITE\WWWROOT\WEBAPPS\ROOT 目录

点击编辑 index.jsp 或者删除这个文件(文件删除后,访问App Service默认URL会返回404错误)

修改index.jsp文件:

如把内容修改为:This is Java Site...保存后,在浏览器中再次访问App Service

 

删除index.jsp文件

以上方式均可以避免在App Service的首页暴露 服务端Tomcat 信息!

 

默认生成的Index.jsp 内容

默认生成的Index.jsp 内容
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                    <title>Microsoft Azure App Service - Welcome</title>
                    <link rel="SHORTCUT ICON" href="https://c.s-microsoft.com/favicon.ico?v2" type="image/x-icon"/>
                    <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/4.1.1/css/bootstrap.min.css" crossorigin="anonymous">
                    <link rel="stylesheet" type="text/css" href="https://appservice.azureedge.net/css/linux-landing-page/v3/main.css">
                    <style>
                        #container {
                            position: relative;
                        }
                        #abc{
                            position: relative;
                            bottom: 0px;
                        }
                        .abc{
                            position: relative;
                            bottom: 0px;
                        }
                    </style>
                    <script type="text/javascript">
                        window.onload=function(){try{var a=window.location.hostname;if(a.includes(".azurewebsites.net")){a=a.replace(".azurewebsites.net", "")}var b=document.getElementById("depCenterLink");b.setAttribute("href", b.getAttribute("href") + "&sitename=" + a);}catch(d){}}
                    </script>
    </head>
    <body>
        <nav class="navbar navbar-light bg-light">
            <a class="navbar-brand " href="#">
                <div class="container pl-4 ml-5">
                    <img src="https://appservice.azureedge.net/images/linux-landing-page/v3/microsoft_azure_logo.png" width="270" height="108" alt=""> </div>
            </a>
        </nav>
        <div class="container-fluid container-height mr-2">
            <div class="pt-10 pb-10 mt-10 mb-10 d-xxs-none d-xs-none d-sm-none d-md-none d-lg-block d-xl-block" style="height:20px; width:100%; clear:both;"></div>
            <div class="row">
                <div class="row col-xs-12 col-sm-12 d-block d-lg-none d-xl-none d-md-block d-sm-block d-xs-block">
                    <div class="text-center">
                        <img src="https://appservice.azureedge.net/images/linux-landing-page/v3/java.svg"> </div>
                </div>
                <div class=" extra-pl-small-scr offset-xl-1 offset-lg-1 offset-md-2 offset-sm-2 offset-xs-4 col-xl-5 col-lg-5 col-md-10 col-sm-11 col-xs-11 div-vertical-center">
                    <div class="container-fluid">
                        <div class="row">
                            <h2>Hey, Java developers!</h2>
                        </div>
                        <br>
                        <div class="row">
                            <h4>Your app service is up and running.</h4>
                        </div>
                        <div class="row">
                            <h4>Time to take the next step and deploy your code.</h4>
                        </div>
                        <div class="row info-mg-top">
                            <p class=" pl-0 col-md-6 col-sm-12 info-mg-top">
                                Have your code ready?<br>
                                    Use deployment center to get code published from your client or setup continuous deployment.<br>
                                        <a id='depCenterLink' href="https://go.microsoft.com/fwlink/?linkid=2057852">
                                            <button class="btn btn-primary btn-mg-top" type="submit">Deployment Center</button>
                                        </a>
                            </p>
                            <p class="pl-0 offset-md-1 col-md-5 col-sm-12 info-mg-top">
                                Don't have your code yet?<br>
                                    Follow our quickstart guide and you'll have a full app ready in 5 minutes or less.<br>
                                        <button onclick="location.href='http://aka.ms/java-quickstart-windows'" class="btn btn-primary btn-mg-top" type="submit">Quickstart</button>
                            </p>
                        </div>
                    </div>
                </div>
                <div class="col-xl-5 col-lg-5 col-md-12 d-none d-lg-block">
                    <div class="text-center">
                        <img src="https://appservice.azureedge.net/images/linux-landing-page/v3/java.svg">
                    </div>
                </div>
                <div class="col-xl-1 col-lg-1 col-md-1"></div>
            </div>
            <div class="row">
                <div class=" extra-pl-small-scr offset-xl-1 offset-lg-1 offset-md-2 offset-sm-2 offset-xs-4 col-xl-5 col-lg-5 col-md-10 col-sm-11 col-xs-11 iv-vertical-center">
                    <div class="container-fluid">
                        <div class="row">
                            <b>Technical Information</b>
                        </div>
                        <div class="row">
                            <%@ page import="java.util.*" %>
                            <%
                                ArrayList<String> mainPageProps = new ArrayList<String>();
                                mainPageProps.add("catalina.base");
                                mainPageProps.add("jetty.base");
                                mainPageProps.add("java.version");
                                mainPageProps.add("java.home");
                                for(String name : mainPageProps)
                                {
                                    String value = System.getProperty(name);
                                    if(value != null)
                                    {
                                        out.print(name + ": " + value + "<br>");
                                    }
                                }
                            %>
                        </div>
                    </div>
                </div>
                <div class="col-xl-5 col-lg-5 col-md-12 d-none d-lg-block"></div>
                <div class="col-xl-1 col-lg-1 col-md-1"></div>
            </div>
        </div>
 
        <!-- Bootstrap core JavaScript==================================================-->
        <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.2.1.min.js" crossorigin="anonymous"></script>
        <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/4.1.1/bootstrap.min.js" crossorigin="anonymous"></script>
    </body>
</html>Java Index Page
相关文章
|
11天前
|
安全
【Azure App Service】App service无法使用的情况分析
App Service集成子网后,如果子网网段中的剩余IP地址非常少的情况下,会在App Service实例升级时( 先加入新实例,然后在移除老实例 )。新加入的实例不能被分配到正确的内网IP地址,无法成功的访问内网资源。 解决方法就是为App Service增加子网地址, 最少需要/26 子网网段地址。
|
20天前
|
开发框架 .NET Windows
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
|
20天前
|
安全 网络安全 Windows
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
|
20天前
|
安全 前端开发 网络安全
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
|
20天前
|
开发框架 JavaScript 前端开发
【App Service】解决 .NET Profiler 报告打开后无数据加载的问题
【App Service】解决 .NET Profiler 报告打开后无数据加载的问题
|
20天前
|
存储 Linux 网络安全
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Linux/Linux Container)
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Linux/Linux Container)
|
20天前
|
开发框架 前端开发 JavaScript
【Azure App Service】.NET应用读取静态文件时遇见了404错误的解决方法
【Azure App Service】.NET应用读取静态文件时遇见了404错误的解决方法
|
16天前
|
网络协议 Java 应用服务中间件
tomcat配置域名及HTTPS
tomcat配置域名及HTTPS
|
22天前
|
Java 应用服务中间件 Windows
【应用服务 App Service】App Service 中部署Java项目,查看Tomcat配置及上传自定义版本
【应用服务 App Service】App Service 中部署Java项目,查看Tomcat配置及上传自定义版本
|
4月前
|
安全 网络协议 应用服务中间件
tomcat 状态页 及常见配置
tomcat 状态页 及常见配置