deepseek-r1本地化部署之后使用nginx配置外網(wǎng)

0、前提

已根據(jù)deepseek-r1本地化部署部署好了環(huán)境,能通過http://localhost:3000打開open-webui的頁面。

1、添加nginx 的配置文件

假設(shè)你的域名是deepseek.example.com
在/etc/nginx/conf.d目錄下創(chuàng)建對應(yīng)的配置文件,文件名為deepseek.example.com.conf
文件內(nèi)容如下:

server {
    listen 80;
    server_name deepseek.example.com;
}

使用certbot配置ssl,如果沒有安裝certbot,參考Linux CentOS 7 使用certbot管理nginx證書

certbot --nginx

按照步驟一步一步操作最終文件如下:

server {
    server_name deepseek.example.com;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/deepseek.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/deepseek.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}server {
    if ($host = deepseek.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name deepseek.example.com;
    return 404; # managed by Certbot
}

修改該文件,添加http和ws轉(zhuǎn)發(fā),最終文件如下:


server {
    server_name deepseek.example.com;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/deepseek.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/deepseek.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

location /ws {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass http://127.0.0.1:3000;
}

    
  location / {
    proxy_pass http://localhost:3000;
    proxy_read_timeout      3600;
    proxy_connect_timeout   300;
    proxy_redirect          off;
    proxy_http_version 1.1;
    proxy_set_header Host $http_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 http;

    }
}server {
    if ($host = deepseek.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name deepseek.example.com;
    return 404; # managed by Certbot
}

重啟nginx

nginx -s reload

2、配置完成之后打開對應(yīng)域名驗(yàn)證

打開https://deepseek.example.com/
不出意外的話就出意外了
模型都加載不出來,按下F12,發(fā)現(xiàn)控制臺出現(xiàn)“WebUI could not connect to Ollama”

解決方案:

1.點(diǎn)擊頭像 - 管理員面板


image.png

2.點(diǎn)擊設(shè)置 - 外部鏈接 - 配置


image.png

3.點(diǎn)擊刷新按鈕會出現(xiàn)驗(yàn)證失敗提示
image.png

4.添加ollama配置

systemctl edit ollama.service

添加如下內(nèi)容

[Service]
Environment="OLLAMA_HOST=0.0.0.0"

重啟ollama

systemctl daemon-reload
systemctl restart ollama

5、返回第4步驗(yàn)證

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容