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
相关推荐
阿虎儿18 小时前
Docker安装(非sudo用户可用)
docker
Johny_Zhao1 天前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
fetasty2 天前
rustfs加picgo图床搭建
docker
蝎子莱莱爱打怪3 天前
GitLab CI/CD + Docker Registry + K8s 部署完整实战指南
后端·docker·kubernetes
chlk1233 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑3 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件3 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号3 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash4 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
小p4 天前
docker学习7:docker 容器的通信方式
docker