1

我在 Centos 7 的 Docker 容器中的 Commandbox 中运行了一个 Lucee 应用程序。

Docker version 1.13.1, build 0be3e21/1.13.1
CentOS Linux release 7.9.2009 (Core)
Commandbox v5.2.1+00295
Lucee 5.3.7.47

/app应用程序代码在启动时通过 Dockerfile复制到目录中:

COPY . /app

我想查看/app目录中的一个点文件(隐藏文件) /app/.build,.

如果我浏览到 http://app_name.com/.build,我会收到 404 错误(未找到)。

如果我通过以下命令将文件重命名为 build.json:

cp .build build.json

然后我可以通过 http://app_name.com/build.json 查看它

我尝试在 server.json 文件中创建以下条目:

"rewrites":{
    "enable":true,
    "config":"customRewrites.xml"
},

以及 customRewrites.xml 文件中的以下规则:

<rule>
    <from>\.build$</from>
    <set type="content-type">text-html</set>
    <to last="true">\.build</to>
</rule>

添加完整的 Dockerfile 以提高清晰度:

FROM ortussolutions/commandbox
COPY . /app
COPY ./config/ /config/
ENV LUCEE_EXTENSIONS D4EDFDBD-A9A3-E9AF-597322D767E0C949;name=Oracle;version=11.2.0.4
WORKDIR $APP_DIR
RUN box install

经过进一步调查,我发现问题似乎是在启动时没有创建 /usr/local/lib/serverHome/WEB-INF/urlrewrite.xml 文件。启动期间的日志表明正在读取重写: --urlrewrite-enable true --urlrewrite-file /app/customRewrites.xml

4

1 回答 1

0

我发现 Commandbox 5.2 中默认的 urlRewrite.xml 文件具有以下代码来阻止隐藏文件:

<rule>
    <condition type="request-uri" operator="equal">.*/\..*</condition>
    <from>^/(.+)$</from>
    <set type="status">404</set>
    <to type="passthrough" last="true">/404.html</to>
</rule>
于 2021-03-02T18:58:55.960 回答