mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-19 08:51:55 +08:00
Compare commits
2 Commits
37159758f1
...
55a287f93a
Author | SHA1 | Date | |
---|---|---|---|
|
55a287f93a | ||
c04f600332 |
@ -6,6 +6,7 @@ services:
|
|||||||
- "3336:3336"
|
- "3336:3336"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
|
- ./favicon:/app/favicon
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
- OAUTH_CLIENT_ID=your_client_id
|
- OAUTH_CLIENT_ID=your_client_id
|
||||||
|
2
favicon/.gitkeep
Normal file
2
favicon/.gitkeep
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 这个文件确保 favicon 目录被 git 跟踪
|
||||||
|
# 用户可以在这个目录中放置自定义的 favicon.ico 文件
|
32
favicon/README.md
Normal file
32
favicon/README.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Favicon 自定义设置
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
1. 将你的 favicon 文件重命名为 `favicon.ico`
|
||||||
|
2. 放置在这个 `favicon` 目录中
|
||||||
|
3. 重启 proxy-go 服务
|
||||||
|
|
||||||
|
## 支持的文件格式
|
||||||
|
|
||||||
|
- `.ico` 文件(推荐)
|
||||||
|
- `.png` 文件(需要重命名为 favicon.ico)
|
||||||
|
- `.jpg/.jpeg` 文件(需要重命名为 favicon.ico)
|
||||||
|
- `.svg` 文件(需要重命名为 favicon.ico)
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
- 文件必须命名为 `favicon.ico`
|
||||||
|
- 推荐尺寸:16x16, 32x32, 48x48 像素
|
||||||
|
- 如果没有放置文件,将返回 404(浏览器会使用默认图标)
|
||||||
|
|
||||||
|
## 示例
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 将你的 favicon 文件复制到这个目录
|
||||||
|
cp your-favicon.ico ./favicon/favicon.ico
|
||||||
|
|
||||||
|
# 重启服务
|
||||||
|
docker-compose restart
|
||||||
|
```
|
||||||
|
|
||||||
|
现在访问 `http://your-domain.com/favicon.ico` 就会显示你的自定义 favicon 了!
|
4
go.mod
4
go.mod
@ -1,8 +1,8 @@
|
|||||||
module proxy-go
|
module proxy-go
|
||||||
|
|
||||||
go 1.24
|
go 1.23.0
|
||||||
|
|
||||||
toolchain go1.24.4
|
toolchain go1.23.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/andybalholm/brotli v1.1.1
|
github.com/andybalholm/brotli v1.1.1
|
||||||
|
19
main.go
19
main.go
@ -129,6 +129,25 @@ func main() {
|
|||||||
matcher func(*http.Request) bool
|
matcher func(*http.Request) bool
|
||||||
handler http.Handler
|
handler http.Handler
|
||||||
}{
|
}{
|
||||||
|
// favicon.ico 处理器
|
||||||
|
{
|
||||||
|
matcher: func(r *http.Request) bool {
|
||||||
|
return r.URL.Path == "/favicon.ico"
|
||||||
|
},
|
||||||
|
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// 检查是否有自定义favicon文件
|
||||||
|
faviconPath := "favicon/favicon.ico"
|
||||||
|
if _, err := os.Stat(faviconPath); err == nil {
|
||||||
|
// 设置正确的Content-Type和缓存头
|
||||||
|
w.Header().Set("Content-Type", "image/x-icon")
|
||||||
|
w.Header().Set("Cache-Control", "public, max-age=31536000") // 1年缓存
|
||||||
|
http.ServeFile(w, r, faviconPath)
|
||||||
|
} else {
|
||||||
|
// 如果没有自定义favicon,返回404
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
},
|
||||||
// 管理路由处理器
|
// 管理路由处理器
|
||||||
{
|
{
|
||||||
matcher: func(r *http.Request) bool {
|
matcher: func(r *http.Request) bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user