https://zeabur.com/templates/77FSH6
searXNG (feat: lobehub 但我用的是网上公开的)
https://github.com/open-webui/open-webui
open-webui (之前的ollama webui)
https://openwebui.com/f/coker/gemini
owu 插件函数,用于实现Gemini完全体
https://github.com/Calcium-Ion/new-api
new api 用于中转/合并/重定向/负载均衡
还是反向代理爽,直接加速窜稀
# OpenResty 完整配置
# 工作进程配置
worker_processes auto; # 根据 CPU 核心数自动设置工作进程数
worker_cpu_affinity auto; # 自动绑定工作进程到 CPU 核心 (推荐)
# 错误日志配置
error_log logs/error.log notice; # 定义错误日志级别 (debug, info, notice, warn, error, crit, alert, emerg)
# 事件配置
events {
worker_connections 10000; # 设置每个工作进程的最大连接数
use epoll; # 使用 epoll 高效事件驱动模型 (Linux)
}
# HTTP 配置
http {
include mime.types; # 包含 MIME 类型定义
default_type application/octet-stream; # 设置默认 MIME 类型
# 设置日志格式
log_format main '[imath:0]remote_addr - [/imath:0]remote_user [[imath:0]time_local] "[/imath:0]request" '
'[imath:0]status [/imath:0]body_bytes_sent "[imath:0]http_referer" '
'"[/imath:0]http_user_agent" "[imath:0]http_x_forwarded_for"';
# 开启访问日志
access_log logs/access.log main;
sendfile on; # 开启 sendfile 系统调用,提高文件传输效率
#tcp_nopush on; # 开启 tcp_nopush (只有在 sendfile 开启时才有效) # 注释掉,因为下面的配置包含了更细粒度的控制
#tcp_nodelay on; # 开启 tcp_nodelay # 注释掉,因为下面的配置包含了更细粒度的控制
# 开启长连接
keepalive_timeout 65; # 设置长连接超时时间
# 配置 Gzip 压缩
gzip on;
gzip_min_length 1000; # 只有大于 1000 字节的响应才进行压缩
gzip_proxied any; # 允许对所有代理的请求进行压缩
gzip_types text/plain application/xml application/json; # 指定需要压缩的 MIME 类型
# 定义缓存区域
proxy_cache_path cache levels=1:2 # 设置缓存路径和目录结构
#use_temp_path off # 删除 use_temp_path
max_size=1000m # 设置最大缓存大小
inactive=10m # 设置缓存失效时间
#purger=on # 删除 purger=on
keys_zone=cache_zone:64m
; # 10分钟不访问则失效
proxy_cache_key "[/imath:0]scheme[imath:0]request_method[/imath:0]host[imath:0]request_uri[/imath:0]is_args$args"; # 定义缓存的key
# upstream backend { # 可以定义上游服务器组,如果你的后端服务是集群的话
# server 11.45.14.10:3000;
# #server 11.45.14.11:3000; # 可以添加多个server
# keepalive 32; # 建议开启, 保持与上游的连接
# }
# server 配置
server {
listen 80; # 监听端口
server_name localhost; # 设置服务器名
# 禁用默认欢迎页面
location = / {
return 403;
}
# 优化小文件传输, 降低延迟
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2?|ttf|eot|svg)$ {
expires 30d; # 缓存30天
open_file_cache max=10000 inactive=30s; # 缓存打开的文件
open_file_cache_valid 60s;
open_file_cache_min_uses 2;
tcp_nopush on; # 开启
tcp_nodelay off; # 关闭
sendfile on;
}
# 优化大文件传输
location ~* \.(mp4|webm|ogg|mp3)$ {
expires 30d;
sendfile on;
tcp_nopush on;
tcp_nodelay on; # 开启
# 配置 HLS 或 DASH
# ...
}
location = /api/models {
proxy_pass http://11.45.14.10:3000; # 使用 upstream 指令
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
proxy_ssl_server_name off;
proxy_ssl_name $proxy_host;
add_header Strict-Transport-Security "max-age=31536000";
proxy_ignore_headers Set-Cookie Cache-Control expires;
proxy_cache_bypass $http_upgrade; # add these two lines
proxy_no_cache $http_upgrade;
proxy_cache cache_zone;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 301 302 10m;
# 开启Websocket支持
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
error_log logs/api_models_error.log error; # 为这个location添加特定的错误日志
}
location = /api/version/updates {
proxy_pass http://11.45.14.10:3000; # 使用 upstream 指令
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
proxy_ssl_server_name off;
proxy_ssl_name $proxy_host;
add_header Strict-Transport-Security "max-age=31536000";
proxy_ignore_headers Set-Cookie Cache-Control expires;
proxy_cache_bypass $http_upgrade; # add these two lines
proxy_no_cache $http_upgrade;
proxy_cache cache_zone;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 301 302 10m;
# 开启Websocket支持
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
error_log logs/api_version_updates_error.log error; # 为这个location添加特定的错误日志
}
# Lua 脚本示例 (OpenResty 强大之处)
location /hello {
default_type text/html;
content_by_lua_block {
ngx.say("<h1>Hello, OpenResty!</h1>")
}
}
} # server结束
# HTTP 结束
}
部分自定义配置
https://linux.do/t/topic/506938
还有在论坛里面帮别人解决问题时用deno写的反向代理
https://github.com/stevessr/small-things/blob/main/reverse_http.ts
可部署在
https://dash.deno.com/
支持http&https、ws&wss,用于隐藏原服务器