当前位置: 首页 > news >正文

网站系统与网站源码的关系优化网站的方法

网站系统与网站源码的关系,优化网站的方法,郑州建设企业网站,黄石做网站场景 本地部署deepseek模型,用的Ollama管理,内网穿透到公网,在通过nginx反代ollama接口。 问题描述 跨域问题 nginx转发时请求头中需要加入origin,并且origin还要和ollama接口同源(协议、ip、端口一致)。…

场景

本地部署deepseek模型,用的Ollama管理,内网穿透到公网,在通过nginx反代ollama接口。


问题描述

  1. 跨域问题
  • nginx转发时请求头中需要加入origin,并且origin还要和ollama接口同源(协议、ip、端口一致)。
proxy_set_header origin http://ip:11434;
  1. 无法逐字输出
  • 关键配置:禁用缓冲和缓存
proxy_buffering off;
proxy_cache off;
  • 确保流式传输的实时性
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;

完整配置

server {listen 80;server_name 域名;return 301 https://$server_name$request_uri;
}
server {listen 443 ssl;server_name 域名;#ssl证书配置ssl_certificate      /opt/nginx/conf/ssl/xxx/fullchain.pem;ssl_certificate_key  /opt/nginx/conf/ssl/xxx/key.pem;ssl_session_cache    shared:SSL:1m;ssl_session_timeout  5m;ssl_ciphers  HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers  on;# 反代到 Ollama APIlocation /api/ {# Ollama 默认端口是 11434proxy_pass  http://服务器IP:11434;  # 请求时的origin请求头proxy_set_header origin http://服务器IP:11434;# 关闭 Nginx 的响应缓冲,强制数据实时传输到客户端proxy_buffering off;# 使用 HTTP/1.1 以支持长连接,避免 HTTP/1.0 的短连接问题proxy_cache off;# 确保流式传输的实时性proxy_set_header Connection '';proxy_http_version 1.1;# 关闭 Nginx 的分块编码处理(根据实际情况调整)chunked_transfer_encoding off;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;# 添加 CORS 头部add_header 'Access-Control-Allow-Origin' '*' always;add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;# 处理预检请求 (OPTIONS)if ($request_method = 'OPTIONS') {add_header 'Access-Control-Allow-Origin' '*';add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';add_header 'Access-Control-Max-Age' 1728000;add_header 'Content-Type' 'text/plain; charset=utf-8';add_header 'Content-Length' 0;return 204;}}
}

http://www.hengruixuexiao.com/news/49990.html

相关文章:

  • 江苏工信部网站备案上海网络推广排名公司
  • 网站广告推广技巧分享免费查权重工具
  • 常德市住房和城市建设局网站小白如何学电商运营
  • 邯郸网站制作找谁什么是互联网销售
  • 热门图片素材长沙优化排名
  • 力洋童装批发网站青岛seo霸屏
  • 美容评测网站建设分析报告永久免费wap自助建站
  • 在菲律宾做网络网站犯法吗网站seo分析案例
  • 做网站的思路怎么写广东seo推广哪里好
  • 微信小程序二次开发英文seo是什么意思
  • 搭建一个网站的基本流程windows优化大师可以卸载吗
  • 北京做网站建设公司百度网盘搜索入口
  • 谷城网站制作宝安网站建设
  • 北京服务网江苏关键词推广seo
  • 兰州网站移动端优化怎么卸载windows优化大师
  • 男女做那个能看的视频网站google play官网下载
  • 长沙网站优化公司常用的seo工具的是有哪些
  • 大连做网站seo网站快速收录教程
  • 个人做房产网站windows优化大师要会员
  • dedecms 做电商网站seo交流中心
  • 郑州企业网站优化多少钱长沙网络推广服务
  • 假淘宝网站怎么做安卓优化大师新版
  • 火车头更新wordpress商品标题seo是什么意思
  • 招聘网站比对表怎么做热点军事新闻
  • 网站优化 检测响应速度seo公司发展前景
  • 遂川网站建设百度网盘资源搜索引擎搜索
  • 川畅联系 做网站多少钱网销平台排名
  • 成都机械网站制作网络推广的主要内容
  • 公众平台账号授权怎么弄福州搜索引擎优化公司
  • 山东临沂网站建设2021十大网络舆情案例