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 结果:没有任何返回内容

请帮忙分析原因。

相关推荐
神经星星10 分钟前
【vLLM 教程】使用 TPU 安装
数据库·人工智能·机器学习
后端小肥肠13 分钟前
解锁DeepSpeek-R1大模型微调:从训练到部署,打造定制化AI会话系统
大数据·人工智能
卧式纯绿14 分钟前
每天一篇《目标检测》文献(一)
人工智能·yolo·目标检测·计算机视觉·cnn
Baihai_IDP17 分钟前
7B 开源模型性能超越 LLaVA,DeepSeek Janus Pro 论文详解
人工智能·llm·deepseek
HeteroCat32 分钟前
【7层追问】prompt模板,AI告诉了我创业的真相
人工智能·llm
迅易科技34 分钟前
破局企业AI落地难题!迅易科技DeepSeek私有化部署全场景解决方案
人工智能·科技·持续部署·deepseek
zlt200041 分钟前
Spring AI与DeepSeek实战二:打造企业级智能体
人工智能·spring boot·deepseek
RuizhiHe1 小时前
从零开始实现大语言模型(十四):高阶训练技巧
人工智能·chatgpt·llm·大语言模型·deepseek·从零开始实现大语言模型
hjehheje1 小时前
clickhouse源码分析
人工智能
hjehheje1 小时前
clickhouse查询效率低
数据库·人工智能