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 用于中转/合并/重定向/负载均衡
还是反向代理爽,直接加速窜稀
# worker 和 events 部分保持不变喵~
worker_processes auto;
worker_cpu_affinity auto;
pid /www/server/nginx/nginx.pid;
error_log logs/error.log notice;
events {
worker_connections 1024;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
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;
keepalive_timeout 65;
gzip on;
# ... (gzip 配置保持不变) ...
gzip_types text/plain text/css application/json application/javascript application/xml text/xml image/svg+xml;
proxy_cache_path cache levels=1:2 keys_zone=cache_zone:64m max_size=1000m
inactive=10m use_temp_path=off;
proxy_cache_key "[/imath:0]scheme[imath:0]request_method[/imath:0]host[imath:0]request_uri[/imath:0]is_args$args";
server {
listen 443 ssl;
listen 80;
server_name https.local; # master 可能需要添加其他域名喵~
# SSL 配置 (只对 443 生效喵)
ssl_certificate /home/stevessr/selfsigned.crt;
ssl_certificate_key /home/stevessr/selfsigned.key;
# ... (其他 SSL 配置保持不变) ...
ssl_session_timeout 10m;
# --- 全局/默认的代理设置喵 ---
# 这些会被下面 location 里的 proxy_pass 继承哦
proxy_http_version 1.1;
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 X-Forwarded-Proto $scheme;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_read_timeout 3600s; # 默认超时,特殊 location 可以覆盖喵~
proxy_send_timeout 3600s; # 默认超时
proxy_cache_bypass $http_upgrade; # 对大部分代理都适用的 bypass 规则
proxy_no_cache $http_upgrade; # 对大部分代理都适用的 no_cache 规则
# 全局 sub_filter (如果 master 希望它们全局生效的话)
# 注意: 这些会影响所有响应体,master 确定吗?喵?
sub_filter_once off; # 通常标题只替换一次就够了喵
sub_filter '<title>Open WebUI</title>' '<title>加载中</title>';
sub_filter '"name":"Open WebUI"' '"name":"neko"';
# 奴家暂时注释掉全局 sub_filter,它们放在 HTTPS 的 server 块里可能更合适?或者只在特定 location?
root /mnt/disk/opwebui/.venv/lib/python3.12/site-packages/open_webui/frontend;
index index.html index.htm;
location /op {
alias /mnt/disk/op/;
autoindex on;
sendfile on;
tcp_nopush on;
expires 30d;
add_header Cache-Control "public";
}
location /admin {
alias /mnt/disk/opwebui/.venv/lib/python3.12/site-packages/open_webui/frontend/;
autoindex on;
sendfile on;
tcp_nopush on;
expires 30d;
add_header Cache-Control "public";
}
location /api/v1 {
proxy_pass http://127.0.0.1:8088;
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 X-Forwarded-Proto $scheme; # $scheme 会根据实际连接是 http 还是 https 正确设置喵
proxy_set_header REMOTE-HOST $remote_addr;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_cache_bypass $http_upgrade;
proxy_no_cache $http_upgrade;
add_header X-Cache $upstream_cache_status;
# HSTS header removed here. 原来的 HSTS 头已被注释或删除,因为它不应在 HTTP 上发送
# --- 处理请求体的 Lua 脚本 (保持不变) ---
access_by_lua_block {
local method = ngx.var.request_method
if method == "POST" or method == "PUT" or method == "PATCH" then
ngx.req.read_body()
local body_data = ngx.req.get_body_data()
if body_data then
local new_body_data, count = string.gsub(body_data, "/op/", "https://op.aaca.eu.org/")
if count and count > 0 then
ngx.req.set_body_data(new_body_data)
ngx.req.set_header("Content-Length", #new_body_data)
end
end
end
}
# --- 处理响应体的 sub_filter (保持不变) ---
sub_filter_types application/json;
body_filter_by_lua_block {
if ngx.var.remote_addr ~= "127.0.0.1" then
local chunk = ngx.arg[1]
local eof = ngx.arg[2]
if chunk then
chunk = string.gsub(chunk, "https://op.aaca.eu.org", "/op")
ngx.arg[1] = chunk
end
if eof then
ngx.arg[2] = true
end
else
local chunk = ngx.arg[1]
local eof = ngx.arg[2]
if chunk then
chunk = string.gsub(chunk, "/op/", "https://op.aaca.eu.org/")
ngx.arg[1] = chunk
end
if eof then
ngx.arg[2] = true
end
end
}
sub_filter_once off;
proxy_hide_header Content-Length;
chunked_transfer_encoding on;
}
location /api {
proxy_pass http://127.0.0.1:8088;
# 继承了大部分 proxy_set_header 和超时设置
proxy_cache cache_zone;
proxy_cache_key $host$uri$is_args$args; # 这个 key 可能不需要 $scheme 了,因为 Host 包含了域名
proxy_cache_valid 200 304 1m;
proxy_cache_valid 301 302 10m;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_lock on;
add_header X-Cache $upstream_cache_status;
proxy_set_header Accept-Encoding ""; # 这个是特殊的,留在这里喵~
sub_filter_once off;
sub_filter_types application/json;
sub_filter '(Open WebUI)' 'neko';
proxy_ignore_headers Set-Cookie Cache-Control expires;
# Lua 响应体处理 (保持不变)
body_filter_by_lua_block {
if ngx.var.remote_addr ~= "127.0.0.1" then
local chunk = ngx.arg[1]
local eof = ngx.arg[2]
if chunk then
chunk = string.gsub(chunk, "https://op.aaca.eu.org", "/op")
ngx.arg[1] = chunk
end
if eof then
ngx.arg[2] = true
end
else
local chunk = ngx.arg[1]
local eof = ngx.arg[2]
if chunk then
chunk = string.gsub(chunk, "/op/", "https://op.aaca.eu.org/")
ngx.arg[1] = chunk
end
if eof then
ngx.arg[2] = true
end
end
}
}
location /ws {
proxy_pass http://127.0.0.1:8088;
# 继承了大部分 proxy_set_header
# 下面是 WebSocket 特有的喵~
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 覆盖默认超时
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
location /ollama {
proxy_pass http://127.0.0.1:8088;
# 继承了大部分 proxy_set_header 和默认超时
proxy_buffering off; # 特殊设置保留喵~
}
location /mcpo/ {
proxy_pass http://127.0.0.1:8003/; # 看,还是去 8003 喵~
# 继承了大部分 proxy_set_header
# WebSocket 相关 header
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 覆盖默认超时
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
location ~ ^/(c|channels|workspace|admin)/ {
try_files $uri $uri/ /index.html;
}
location ~ ^/static/(?:logo|splash|favicon)\.(png|ico|svg)$ {
alias /mnt/disk/op/sp/favicon.$1;
expires 30d;
add_header Cache-Control "public";
}
location / {
try_files $uri $uri/ /index.html;
expires -1;
add_header Cache-Control "no-store";
}
location ~ /\. {
deny all;
}
location = /index.html {
sub_filter '<title>Open WebUI</title>' '<title>加载中</title>';
body_filter_by_lua_block {
if ngx.var.remote_addr ~= "127.0.0.1" and ngx.var.uri == "/api/models" then
local chunk = ngx.arg[1]
local eof = ngx.arg[2]
if chunk then
chunk = string.gsub(chunk, "/static/", "https://op.aaca.eu.org/sp/")
chunk = string.gsub(chunk, "https://op.aaca.eu.org", "/op")
ngx.arg[1] = chunk
end
if eof then
ngx.arg[2] = true
end
end
}
sub_filter_once off;
}
}
}
更新了,llm的喵就不去了
部分自定义配置
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,用于隐藏原服务器