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

Ollama在AutoDL部署,CPU服务器做代理,实践中

## 我有两台服务器,一台是GPU服务器,另一台是CPU服务器;

## 我在GPU服务器上安装了Ollama,然后通过命令映射端口到CPU服务器:

ssh -CNg -L 0.0.0.0:11434:127.0.0.1:11434 root@connect.westb.seetacloud.com -p 34016

## 映射成功了在Cpu服务器通过curl http://127.0.0.1:11434 可以看到响应内容:

Ollama is running

内网IP,也可以看到内容:

curl http://192.168.0.137:11434


 

## 我现在想通过nginx 代理下,把ollama服务开放到公网

server {

listen 80;

server_name ollama.guifanhua.com;

location / {

proxy_pass http://127.0.0.1:11434;

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;

}

}

## 域名解析是没问题的,但是公网无论如何都不能代理成功,在公网访问:http://ollama.guifanhua.com的时候报错:

找不到 ollama.guifanhua.com 的网页

找不到与以下网址对应的网页:http://ollama.guifanhua.com/

HTTP ERROR 404

## 检查systemctl status firewalld:

Unit firewalld.service could not be found.

## 检查firewall-cmd --list-all返回:

public (active)

target: default

icmp-block-inversion: no

interfaces: eth0

sources:

services: dhcpv6-client ssh

ports:

protocols:

forward: yes

masquerade: no

forward-ports:

source-ports:

icmp-blocks:

rich rules:

## 检查getenforce 返回:

Disabled

## telnet ollama.guifanhua.com 80

一直都是:正在连接ollama.guifanhua.com...

## 检查 netstat -tulpn | grep :80,返回:

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1565809/nginx: mast

tcp6 0 0 :::80 :::* LISTEN 1565809/nginx: mast

## 检查netstat -tulpn | grep :11434 返回:

tcp 0 0 0.0.0.0:11434 0.0.0.0:* LISTEN 1595287/ssh

## 检查80端口:firewall-cmd --permanent --add-port=80/tcp 返回:

success

## firewall-cmd --reload 返回

success

## 检查域名解析:nslookup ollama.guifanhua.com

Server: 127.0.0.53

Address: 127.0.0.53#53

Non-authoritative answer:

Name: ollama.guifanhua.com

Address: 1.95.50.15

# 检查nginx状态 systemctl status nginx 返回:

nginx.service - A high performance web server and a reverse proxy server

Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2025-03-06 23:56:45 CST; 9h ago

Docs: man:nginx(8)

Main PID: 1565809 (nginx)

Tasks: 9 (limit: 18587)

Memory: 10.3M

CPU: 242ms

CGroup: /system.slice/nginx.service

├─1565809 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"

├─1594458 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

├─1594459 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

├─1594460 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

├─1594461 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

├─1594462 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

├─1594463 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

├─1594464 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

└─1594465 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Mar 06 23:56:45 flexusx-f89b systemd[1]: Starting A high performance web server and a reverse proxy server...

Mar 06 23:56:45 flexusx-f89b systemd[1]: Started A high performance web server and a reverse proxy server.

# 检查nginx错误日志tail -f /var/log/nginx/error.log 返回:

2025/03/07 03:14:25 [error] 1565810#1565810: *299 connect() failed (111: Unknown error) while connecting to upstream, client: 123.249.97.106, server: ollama.guifanhua.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:11434/", host: "ollama.guifanhua.com", referrer: "https://www.baidu.com"

2025/03/07 08:34:39 [error] 1565810#1565810: *450 connect() failed (111: Unknown error) while connecting to upstream, client: 1.95.50.15, server: ollama.guifanhua.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:11434/", host: "ollama.guifanhua.com"

2025/03/07 08:34:48 [error] 1565810#1565810: *452 connect() failed (111: Unknown error) while connecting to upstream, client: 1.95.50.15, server: ollama.guifanhua.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:11434/", host: "ollama.guifanhua.com"

2025/03/07 08:34:59 [error] 1565810#1565810: *454 connect() failed (111: Unknown error) while connecting to upstream, client: 1.95.50.15, server: ollama.guifanhua.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:11434/", host: "ollama.guifanhua.com"

2025/03/07 08:43:32 [notice] 1594232#1594232: signal process started

2025/03/07 08:44:21 [notice] 1594260#1594260: signal process started

2025/03/07 08:47:49 [notice] 1594457#1594457: signal process started

# 检查nginx访问日志tail -f /var/log/nginx/access.log

199.45.154.135 - - [07/Mar/2025:09:05:37 +0800] "GET / HTTP/1.1" 200 3522 "-" "Mozilla/5.0 (compatible; CensysInspect/1.1; +https://about.censys.io/)" "-"

199.45.154.135 - - [07/Mar/2025:09:05:53 +0800] "PRI * HTTP/2.0" 400 166 "-" "-" "-"

199.45.154.135 - - [07/Mar/2025:09:05:58 +0800] "GET /favicon.ico HTTP/1.1" 404 134 "-" "Mozilla/5.0 (compatible; CensysInspect/1.1; +https://about.censys.io/)" "-"

199.45.154.135 - - [07/Mar/2025:09:06:00 +0800] "\x16\x03\x01\x00\xF7\x01\x00\x00\xF3\x03\x03*\x8B\xA8V\xBF?\xFB=\x89R\x02\xF5\xB5{\x9Ezg\xC16>\xDD\xCFG\x82\x82*\xFD\xBEZ\xE2u\x06 ^\xA8\x95\xE2\x0CQ\x95\x1Dc\x88\x96 \x89[\xFD\x89\x90\x83b\x8E\xBE=>\xEC.\xB2Z\x89P}\xEB\xCB\x00&\xCC\xA8\xCC\xA9\xC0/\xC00\xC0+\xC0,\xC0\x13\xC0\x09\xC0\x14\xC0" 400 166 "-" "-" "-"

194.165.16.163 - - [07/Mar/2025:09:06:26 +0800] "\x03\x00\x00/*\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Administr" 400 166 "-" "-" "-"

211.94.136.254 - - [07/Mar/2025:09:10:12 +0800] "GET / HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" "-"

211.94.136.254 - - [07/Mar/2025:09:10:12 +0800] "GET / HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" "-"

211.94.136.254 - - [07/Mar/2025:09:10:13 +0800] "GET / HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" "-"

211.94.136.254 - - [07/Mar/2025:09:10:13 +0800] "GET / HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" "-"

211.94.136.254 - - [07/Mar/2025:09:10:13 +0800] "GET / HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" "-"

# 测试nginx配置curl -H "Host: ollama.guifanhua.com" http://localhost 结果:没有任何返回内容

## 请帮忙分析原因。


http://www.kler.cn/a/575926.html

相关文章:

  • ARM M3核心介绍
  • Java岗高频算法题精讲(LeetCode+场景化拆解)
  • Jetson Orin 安装 onnxruntime
  • *图论基础(5)
  • 在 CLion 中使用 Google Test 进行单元测试
  • ASP.NET 微服务网关 Ocelot+Consul+Skywalking
  • 【前端跨域】WebSocket如何实现跨域通信?原理、实践与安全指南
  • 揭开AI-OPS 的神秘面纱 第二讲-技术架构与选型分析 -- 数据采集层技术架构与组件选型分析
  • 软考架构师笔记-计算机网络
  • Uniapp项目运行到微信小程序、H5、APP等多个平台教程
  • 基于YOLO11深度学习的运动品牌LOGO检测与识别系统【python源码+Pyqt5界面+数据集+训练代码】
  • 蓝桥杯备考:动态规划路径类DP之矩阵的最小路径和
  • 视频软件编程(iOS)
  • Android Studio 一直 Loading devices
  • Spring Boot静态资源访问顺序
  • ubuntu22.04本地部署OpenWebUI
  • 逐梦 DBA:从数据库概述出发
  • Redis——缓存穿透、击穿、雪崩
  • 【maven】maven依赖报错解决方式
  • 【每日学点HarmonyOS Next知识】对话框回调问题、输入区域最大行数、web自定义节点、icon图标库、软键盘开关