docker 容器web站点 中文文件名访问404问题

一,排查问题经过

1. 检查文件实际名称

在服务器上使用命令确认文件名的实际编码:

2. 系统字符编码设置

确保服务器系统支持UTF-8编码:

java 复制代码
# 检查当前语言环境
locale
# 输出应包含类似:LANG=en_US.UTF-8 或 LANG=zh_CN.UTF-8

# 临时设置为UTF-8(针对当前会话)
export LANG=en_US.UTF-8

# 永久设置:编辑 /etc/environment,添加:
LANG=en_US.UTF-8

3. Web服务器配置

Nginx

在配置文件中明确指定UTF-8编码:

java 复制代码
server {
    charset utf-8;
    ...
}

然而这些改了都没生效还是404

二,最终结果

最后在tomcat的脚本文件catalina.sh文件中加入 . /etc/profile 命令后,重启容器就可以识别到中文文件名了。(重点加. /etc/profile 命令)

javascript 复制代码
# 编辑启动脚本,改用直接设置环境变量
vi /opt/datacenter/project/biframe/start.sh
java 复制代码
# head /usr/local/tomcat/bin/catalina.sh 
#!/bin/sh
. /etc/profile

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at

强制重启

javascript 复制代码
# 强制停止
pkill -9 -f biframe.jar

# 等待几秒确保进程停止
sleep 3

# 重新启动
cd /opt/datacenter/project/biframe/
./start.sh
相关推荐
独隅几秒前
PyTorch 模型部署的 Docker 配置与性能调优深入指南
人工智能·pytorch·docker
报错小能手8 分钟前
深入理解 Linux 虚拟内存管理
开发语言·操作系统
和沐阳学逆向31 分钟前
我现在怎么用 CC Switch 管中转站,顺手拿 Codex 举个例子
开发语言·javascript·ecmascript
小仙女的小稀罕32 分钟前
听不清重要会议录音急疯?这款常见AI工具听脑AI精准转译
开发语言·人工智能·python
mounter62535 分钟前
Linux 7.0 重磅更新:详解 nullfs 如何重塑根文件系统挂载与内核线程隔离
linux·运维·服务器·kernel
书到用时方恨少!38 分钟前
Python random 模块使用指南:从入门到精通
开发语言·python
色空大师1 小时前
【网站搭建实操(一)环境部署】
java·linux·数据库·mysql·网站搭建
客卿1231 小时前
牛客刷题--找数字-- 字符串检测-字符串 双指针
java·开发语言
Amour恋空2 小时前
Java多线程
java·开发语言·python