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
相关推荐
45288655上山打老虎14 分钟前
【智能指针】
开发语言·c++·算法
蜗牛攻城狮22 分钟前
JavaScript 尾递归(Tail Recursion)详解
开发语言·javascript·ecmascript
Dxy123931021624 分钟前
Python的PIL对象crop函数详解
开发语言·python
python百炼成钢31 分钟前
50.linux_USB驱动
linux·运维·服务器·驱动开发
坐吃山猪32 分钟前
Electron04-系统通知小闹钟
开发语言·javascript·ecmascript
翔云 OCR API32 分钟前
护照NFC识读鉴伪接口集成-让身份核验更加智能与高效
开发语言·人工智能·python·计算机视觉·ocr
程序喵大人41 分钟前
CMake入门教程
开发语言·c++·cmake·cmake入门
jay1 小时前
ens2f0 IP 远程连线,balance-alb 模式配置双网卡(ens2f0 + ens6f0)Bond,避免断网
linux·运维·服务器·网络·tcp/ip
半生过往1 小时前
前端运行PHP 快速上手 使用 PHPStudy Pro 详细搭建与使用指南
开发语言·前端·php
zlpzlpzyd1 小时前
ecmascript中Promise和async/await的区别
开发语言·前端·ecmascript