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

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

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

ssh -CNg -L 0.0.0.0:11434:127.0.0.1:11434 [email protected] -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 结果:没有任何返回内容

请帮忙分析原因。

相关推荐
亚里随笔7 分钟前
StreamRL:弹性、可扩展、异构的RLHF架构
人工智能·架构·大语言模型·rlhf·推理加速
RUZHUA17 分钟前
阿里打通内网权限,变革再出发
人工智能
陈奕昆1 小时前
4.3【LLaMA-Factory实战】教育大模型:个性化学习路径生成系统全解析
人工智能·python·学习·llama·大模型微调
wzx_Eleven1 小时前
【论文阅读】基于客户端数据子空间主角度的聚类联邦学习分布相似性高效识别
论文阅读·人工智能·机器学习·网络安全·聚类
ykjhr_3d1 小时前
场景可视化与数据编辑器:构建数据应用情境
人工智能
补三补四1 小时前
遗传算法(GA)
人工智能·算法·机器学习·启发式算法
梁小憨憨1 小时前
循环卷积(Circular Convolutions)
人工智能·笔记·深度学习·机器学习
非凡ghost1 小时前
水印云:AI赋能,让图像处理变得简单高效
图像处理·人工智能
EQ-雪梨蛋花汤1 小时前
【相机标定】OpenCV 相机标定中的重投影误差与角点三维坐标计算详解
人工智能·opencv
向哆哆2 小时前
YOLOv8目标检测性能优化:损失函数改进的深度剖析
人工智能·yolo·目标检测·yolov8