【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
相关文章
|
6月前
|
存储 安全 Linux
【Azure App Service】在App Service中查看CA证书
在 Azure App Service 中,使用自签名或私有 CA 证书的远程服务可能会导致 SSL 握手失败。解决方法包括使用受信任 CA 签发的证书,或通过 App Service Environment 加载自定义根证书,实现安全连接。
155 3
|
7月前
|
域名解析 网络协议 API
【Azure Container App】配置容器应用的缩放规则 Managed Identity 连接中国区 Azure Service Bus 问题
本文介绍了在 Azure Container Apps 中配置基于自定义 Azure Service Bus 的自动缩放规则时,因未指定云环境导致的域名解析错误问题。解决方案是在扩展规则中添加 `cloud=AzureChinaCloud` 参数,以适配中国区 Azure 环境。内容涵盖问题描述、原因分析、解决方法及配置示例,适用于使用 KEDA 实现事件驱动自动缩放的场景。
170 1
|
4月前
|
Java 应用服务中间件 API
【App Service】部署War包到Azure云上遇404错误
Java应用部署至Azure App Service for Windows后报404,本地运行正常。经排查,日志提示类文件版本不兼容:应用由Java 17(class file version 61.0)编译,但环境仅支持到Java 11(55.0)。错误根源为Java版本不匹配。调整App Service的Java版本至17后问题解决,成功访问接口。
221 1
|
4月前
|
存储 Linux 网络安全
【Azure App Service】Root CA on App Service
Azure App Service for Windows应用连接外部SSL服务时,需确保其证书由受信任的根CA颁发。多租户环境下无法修改根证书,但ASE(单租户)可加载自定义CA证书。若遇证书信任问题,可更换为公共CA证书或将应用部署于ASE并导入私有CA证书。通过Kudu的PowerShell(Windows)或SSH(Linux)可查看当前受信任的根证书列表。
126 13
|
5月前
|
网络协议 Java Linux
【App Service】在Azure环境中如何查看App Service实例当前的网络连接情况呢?
在 Azure App Service(Windows 和 Linux)中部署应用时,分析网络连接状态是排查异常、验证端口监听及确认后端连接的关键。本文介绍如何在 Linux 环境中使用 `netstat` 命令查看特定端口(如 443、3306、6380)的连接情况,并解析输出结果。同时说明在 Windows App Service 中 `netstat` 被禁用的情况下,如何通过门户抓包等替代方法进行网络诊断。内容涵盖命令示例、操作步骤及附录说明,帮助开发者快速掌握云环境中的网络分析技巧。
154 11
|
6月前
|
网络协议 关系型数据库 Linux
【App Service Linux】在Linux App Service中安装 tcpdump 并抓取网络包
在App Service for Linux环境中,无法像Windows一样直接使用网络排查工具抓包。本文介绍了如何通过TCPDUMP在Linux环境下抓取网络包,包括SSH进入容器、安装tcpdump、执行抓包命令及下载分析文件的完整操作步骤。
303 5
|
8月前
|
Linux Shell 网络安全
【Azure App Service】使用 tcpping 来获取App Service的网络状态并把结果保存到文本文件中
本文针对云服务使用中网络状态抖动的问题,以Azure App Service为例,介绍如何利用其自带的`tcpping`工具检测网络连通性。通过在Windows或Linux版App Service中执行`tcpping`命令,将结果输出至文本文件,分析timeout行数以判断网络抖动的时间点。文章还提供了具体操作步骤、效果图及参考资料,帮助用户高效排查网络问题。
287 47
|
应用服务中间件 Linux nginx
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
325 77
|
9月前
|
测试技术 Linux 网络安全
【App Services】App Service报错远程证书无效 - "The remote certificate is invalid according to the validation procedure"
在开发环境中,新部署的应用(App Service)无法与 Salesforce 的远程端点建立 SSL/TLS 连接,报错显示证书无效。经分析,防火墙启用了 SSL Inspection,插入了私有 CA 签发的中间证书,导致 App Service 无法验证。解决方案包括禁用 SSL Inspection、设置 `WEBSITE_LOAD_ROOT_CERTIFICATES` 环境变量或临时禁用代码中的 SSL 验证(仅限测试环境)。
270 8