從認證到透傳:用 Nginx 為 EasySearch 構建一體化認證網關

在構建本地或云端搜索引擎系統時,EasySearch 憑借其輕量、高性能、易部署等優勢,逐漸成為眾多開發者和技術愛好者的首選。但在實際部署過程中,如何借助 Nginx 為 EasySearch 提供高效、穩定且安全的訪問入口,尤其是在身份認證方面,仍然是一個關鍵技術環節。

本教程將圍繞 Basic Auth 認證機制展開,系統講解如何通過 Nginx 實現安全防護、認證信息透傳等常見配置場景,幫助你在多種實際部署環境中快速搭建可靠的訪問控制機制。

無論你是在搭建家庭 NAS 服務,還是在企業環境中集成搜索引擎系統,本教程都能為你提供一套可落地、可復用的 Nginx 安全認證解決方案。。

下面是我的 Nginx 配置文件示例。我們通過 Docker 啟動 Nginx 容器,并將本地編寫好的配置文件掛載到容器中,從而實現自定義的反向代理和認證邏輯:

docker run -d \--name my-nginx \-p 80:80 \-v $(pwd)/default.conf:/etc/nginx/conf.d/default.conf \nginx

default.conf配置如下:

server {listen 80;server_name localhost;# 根路徑可選配置,如果你要一個歡迎頁location / {return 200 'Nginx is running.\n';add_header Content-Type text/plain;}# 反向代理 EasySearch location /es/ {proxy_pass https://backend:9200/;# 修正請求頭proxy_http_version 1.1;# proxy_pass_request_headers on; ÷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;# 如果需要保活連接proxy_set_header Connection "";# 可選:允許跨域訪問(用于前端 AJAX 調試)add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';add_header Access-Control-Allow-Headers 'Authorization,Content-Type';# proxy_set_header Authorization "Basic YWRtaW46MTIzNDU2";# 清理路徑前綴 `/es/`rewrite ^/es/(.*)$ /$1 break;}# 可選:靜態資源支持# location /static/ {#     root /usr/share/nginx/html;# }
}

🌐 配置整體結構

server {listen 80;server_name localhost;
  • 監聽端口:監聽本地 80 端口(HTTP 默認端口)
  • 服務名稱:用于匹配請求的 Host,這里是 localhost

🎉 歡迎頁(根路徑 /

location / {return 200 'Nginx is running.\n';add_header Content-Type text/plain;
}
  • 請求 / 會返回純文本響應 "Nginx is running.",可用于驗證 Nginx 是否啟動正常。
  • add_header Content-Type text/plain:指定響應內容為純文本。

🔁 /es/ 代理 EasySearch 后端服務


🚚 請求頭處理

    proxy_http_version 1.1;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;proxy_set_header Connection "";
  • proxy_http_version 1.1:確保代理使用 HTTP/1.1,支持長連接。
  • Host:保留原始請求的主機名。
  • X-Real-IP / X-Forwarded-For:傳遞客戶端真實 IP。
  • X-Forwarded-Proto:傳遞原始協議(http / https)。
  • Connection "":用于避免默認的 keep-alive 設置引起錯誤(推薦保留)。

🔐 可選的認證頭(注釋中)

# proxy_set_header Authorization "Basic YWRtaW46MTIzNDU2";
  • 可選開啟,用于將認證信息轉發到后端。
  • 上面的字符串是 admin:123456 的 base64 編碼。可以根據需要開啟。

🌍 CORS 設置(跨域)

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'Authorization,Content-Type';
  • 允許任意源訪問(前端頁面可以跨域請求 /es/)。
  • 支持的方法:GET、POST、OPTIONS。
  • 允許傳遞的請求頭:Authorization 和 Content-Type。
  • ? 適用于 AJAX 調試、前后端分離等場景。

🔧 URL 重寫

rewrite ^/es/(.*)$ /$1 break;
  • 移除 /es/ 前綴,轉發給后端。例如:
    用戶請求 /es/_cat/indices 實際轉發到 /cat/indices
  • break 表示在當前 location 中中止后續重寫檢查。

📦 可選靜態資源(被注釋掉)

# location /static/ {
#     root /usr/share/nginx/html;
# }
  • 若開啟,可以直接通過 /static/xxx.js 訪問 Nginx 本地 /usr/share/nginx/html/static/xxx.js 文件。

🔁 如果你想保留 /es/ 前綴,則刪除 rewrite 行。


在啟動服務后,當我們通過瀏覽器訪問 Nginx 時,頁面會彈出身份驗證窗口。需要注意的是,這里的認證提示實際上來自后端的 EasySearch 服務,而非 Nginx 本身,說明請求中的認證信息未在 Nginx 層被處理或透傳,因此由 EasySearch 發起了再次認證的要求。

image-20250424165739653

在輸入正確的用戶名和密碼后,我們可以看到 Nginx 成功代理請求,并返回了來自 EasySearch 的 API 響應,說明認證流程已順利通過,后端服務正常可用。

image-20250424165019942

如果希望由 Nginx 代為完成 EasySearch 的身份驗證,也就是實現自動登錄的效果,可以在配置文件中添加如下指令,將認證信息通過 HTTP 頭部傳遞給后端:

proxy_set_header Authorization "Basic YWRtaW46YWRtaW4=";

其中,YWRtaW46YWRtaW4xMjM= 是使用 Base64 編碼后的 用戶名:密碼 字符串(例如 admin:admin)。Nginx 在轉發請求時會自動攜帶該 Header,從而實現對 EasySearch 的自動認證。

需要注意的是,Nginx 的配置文件修改后不會自動生效。為了確保配置被正確加載,需在每次更改配置文件后重啟對應的容器服務。這是容器化部署中常見的操作流程,確保新配置被正確應用。

image-20250424165420050

為了更直觀地觀察請求行為,我們使用了 Postman 進行測試。可以發現,即使在 Postman 中未顯式添加任何認證信息,依然能夠成功訪問 EasySearch 集群。這說明前端未輸入認證信息,但由于 Nginx 曾經緩存了認證狀態,或配置了自動透傳,導致后端依舊接收到了有效的認證頭,從而允許了訪問。

這種現象雖然在測試中提升了訪問便利性,但在實際部署中可能帶來安全風險,因此在生產環境中建議對認證流程進行嚴格控制,確保后端服務不會因為前端認證機制的疏漏而被繞過。

image-20250424165032915

在一些教程中,常會提到一個名為 .htpasswd 的文件,它用于在 Nginx 層實現基本認證。當啟用該機制后,Nginx 會對所有訪問進行用戶身份驗證。

此時,是否將認證信息透傳給后端服務,則由 proxy_pass_request_headers 參數決定。該參數默認值為 on,也就是說,當認證通過后,客戶端發送的 Authorization 頭部信息會被 Nginx 一并轉發給后端服務。

為了驗證這一行為,我編寫了一個簡單的 Flask 程序作為后端,用于觀察請求中的 Header 內容。在真正將請求代理至 EasySearch 之前,我先讓 Nginx 將請求反向代理到這個 Flask 應用,從而可以直觀地查看是否存在 Authorization 頭被透傳的情況。

from flask import Flask, request,abort
import base64
app = Flask(__name__)@app.route('/')
def hello_world():print("📥 Headers received from Nginx:")print("Host:", request.headers.get('Host'))print("X-Real-IP:", request.headers.get('X-Real-IP'))print("X-Forwarded-For:", request.headers.get('X-Forwarded-For'))print("X-Forwarded-Proto:", request.headers.get('X-Forwarded-Proto'))print(request.headers)auth_header = request.headers.get('Authorization')print("Authorization:", auth_header)if not auth_header or not auth_header.startswith('Basic '):abort(401, description="Missing or invalid Authorization header")# 解碼 base64encoded = auth_header.split(' ')[1]decoded = base64.b64decode(encoded).decode('utf-8')  # e.g. admin:123456username, password = decoded.split(':', 1)print(username, password)return 'Hello World!'if __name__ == '__main__':app.run(host='0.0.0.0', port=8000,debug=True)

這個是flask的打印的結果.

Host: secure-nginx.orb.local
X-Real-IP: 192.168.215.1
X-Forwarded-For: 192.168.215.1
X-Forwarded-Proto: http
Host: secure-nginx.orb.local
X-Real-Ip: 192.168.215.1
X-Forwarded-For: 192.168.215.1
X-Forwarded-Proto: http
Authorization: Basic YWRtaW46YWRtaW4=
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh-TW;q=0.9,zh;q=0.8
Cookie: perf_dv6Tr4n=1Authorization: Basic YWRtaW46YWRtaW4=
admin admin
192.168.X.X - - [24/Apr/2025 15:55:59] "GET / HTTP/1.1" 200 -

為了解決雙重認證的問題,我們啟用了認證信息透傳的配置(默認的roxy_pass_request_headers on;)。啟用該配置后,用戶只需在訪問 Nginx 時進行一次手動身份驗證。Nginx 會將用戶提供的憑證通過 HTTP Header 透傳至后端的 EasySearch 服務,從而避免二次認證。當用戶直接訪問 EasySearch 時,依然需要單獨輸入憑證進行認證;但通過 Nginx 訪問時,只需在前端認證一次即可完成整個請求流程。

curl -k https://easysearch:9200        {"error":{"root_cause":[{"type":"security_exception","reason":"Missing authentication information for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"Security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"Missing authentication information for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"Security\" charset=\"UTF-8\""}},"status":401}?                                                                                          
-------curl -v -u "admin:admin" http://nginxhost/es/*   Trying 192.168.5.171:9201...
* Connected to 192.168.5.171 (192.168.5.171) port 9201
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Request CERT (13):
* (304) (IN), TLS handshake, Certificate (11):
* SSL certificate problem: self signed certificate
* Closing connection
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.se/docs/sslcerts.htmlcurl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
* Server auth using Basic with user 'admin'
> GET /es/ HTTP/1.1
> Host: localhost
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Server: nginx/1.27.4
< Date: Thu, 24 Apr 2025 07:45:10 GMT
< Content-Type: application/json; charset=UTF-8
< Content-Length: 552
< Connection: keep-alive
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, OPTIONS
< Access-Control-Allow-Headers: Authorization,Content-Type
< 
{"name" : "easysearch-node1","cluster_name" : "infinilabs","cluster_uuid" : "VcMD__DwSYSUqear8wp-XA","version" : {"distribution" : "easysearch","number" : "1.11.1","distributor" : "INFINI Labs","build_hash" : "4d0be0343919fb1a605e3c8284326b7e069eb9bf","build_date" : "2025-03-14T09:33:12.182925Z","build_snapshot" : false,"lucene_version" : "8.11.4","minimum_wire_lucene_version" : "7.7.0","minimum_lucene_index_compatibility_version" : "7.7.0"},"tagline" : "You Know, For Easy Search!"
}
* Connection #0 to host localhost left intact

本次將 Nginx 的訪問認證密碼修改為 admin123 后,發現在請求過程中出現了兩次身份驗證的提示。具體表現為:當用戶輸入錯誤的密碼時,Nginx 會首先返回一次 401 Unauthorized。由于 Nginx 與 EasySearch 使用了不同的認證信息,Nginx 在將請求頭(包括 Authorization 字段)轉發至 EasySearch 時,EasySearch 檢測到憑據不匹配,也會返回一次 401。由此導致了雙重身份認證失敗的現象,影響了正常訪問流程。

curl -v -u "admin:admin" http://localhost/es/*   Trying 192.168.5.171:9201...
* Connected to 192.168.5.171 (192.168.5.171) port 9201
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Request CERT (13):
* (304) (IN), TLS handshake, Certificate (11):
* SSL certificate problem: self signed certificate
* Closing connection
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.se/docs/sslcerts.htmlcurl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
* Server auth using Basic with user 'admin'
> GET /es/ HTTP/1.1
> Host: localhost
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 401 Unauthorized
< Server: nginx/1.27.4
< Date: Thu, 24 Apr 2025 09:21:09 GMT
< Content-Type: text/html
< Content-Length: 179
< Connection: keep-alive
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Restricted Area"
< 
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.27.4</center>
</body>
</html>
* Connection #0 to host localhost left intact
?xu?~/OrbStack/docker/containers/secure-nginx/etc/nginx??? curl -v https://192.168.5.171:9201/         (base) 17:21:09curl -v -u "admin:admin123" http://localhost/es/*   Trying 192.168.5.171:9201...
* Connected to 192.168.5.171 (192.168.5.171) port 9201
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Request CERT (13):
* (304) (IN), TLS handshake, Certificate (11):
* SSL certificate problem: self signed certificate
* Closing connection
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.se/docs/sslcerts.htmlcurl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
* Server auth using Basic with user 'admin'
> GET /es/ HTTP/1.1
> Host: localhost
> Authorization: Basic YWRtaW46YWRtaW4xMjM=
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 401 Unauthorized
< Server: nginx/1.27.4
< Date: Thu, 24 Apr 2025 09:21:16 GMT
< Content-Type: application/json; charset=UTF-8
< Content-Length: 381
< Connection: keep-alive
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Security" charset="UTF-8"
< 
* Connection #0 to host localhost left intact
{"error":{"root_cause":[{"type":"security_exception","reason":"Missing authentication information for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"Security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"Missing authentication information for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"Security\" charset=\"UTF-8\""}},"status":401}?                             
場景編號Nginx 是否開啟認證EasySearch 是否開啟認證實際認證次數說明
0 次完全開放,任何請求無需驗證。
? 是1 次訪問時直接彈出 EasySearch 的認證窗口,用戶需輸入憑證。
? 是1 次僅在 Nginx 層驗證,驗證通過后直接訪問后端。
? 是? 是2 次(默認)Nginx 和 EasySearch 各自認證,用戶需連續輸入兩次密碼。
? 是? 是1 次(透傳,proxy_pass_request_headers on;)Nginx 開啟認證,并通過 proxy_set_header Authorization 透傳給 EasySearch,用戶僅需輸入一次密碼即可完成認證。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/76981.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/76981.shtml
英文地址,請注明出處:http://en.pswp.cn/web/76981.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

CPU 虛擬化機制——受限直接執行 (LDE)

1. 引言&#xff1a;CPU虛擬化的核心問題 讓多個進程看似同時運行在一個物理CPU上。核心思想是時分共享 (time sharing) CPU。為了實現高效且可控的時分共享&#xff0c;本章介紹了一種關鍵機制&#xff0c;稱為受限直接執行 (Limited Direct Execution, LDE)。 1.1 LDE的基本…

linux 中斷子系統鏈式中斷編程

直接貼代碼了&#xff1a; 虛擬中斷控制器代碼&#xff0c;chained_virt.c #include<linux/kernel.h> #include<linux/module.h> #include<linux/clk.h> #include<linux/err.h> #include<linux/init.h> #include<linux/interrupt.h> #inc…

容器修仙傳 我的靈根是Pod 第10章 心魔大劫(RBAC與SecurityContext)

第四卷&#xff1a;飛升之劫化神篇 第10章 心魔大劫&#xff08;RBAC與SecurityContext&#xff09; 血月當空&#xff0c;林衍的混沌靈根正在異變。 每道經脈都爬滿黑色紋路&#xff0c;神識海中回蕩著蠱惑之音&#xff1a;"破開藏經閣第九層禁制…奪取《太古弒仙訣》……

基于c#,wpf,ef框架,sql server數據庫,音樂播放器

詳細視頻: 【基于c#,wpf,ef框架,sql server數據庫&#xff0c;音樂播放器。-嗶哩嗶哩】 https://b23.tv/ZqmOKJ5

精益數據分析(21/126):剖析創業增長引擎與精益畫布指標

精益數據分析&#xff08;21/126&#xff09;&#xff1a;剖析創業增長引擎與精益畫布指標 大家好&#xff01;在創業和數據分析的探索道路上&#xff0c;我一直希望能和大家攜手共進&#xff0c;共同學習。今天&#xff0c;我們繼續深入研讀《精益數據分析》&#xff0c;剖析…

Spark-streaming核心編程

1.導入依賴?&#xff1a; <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming-kafka-0-10_2.12</artifactId> <version>3.0.0</version> </dependency> 2.編寫代碼?&#xff1a; 創建Sp…

Kafka的ISR機制是什么?如何保證數據一致性?

一、Kafka ISR機制深度解析 1. ISR機制定義 ISR&#xff08;In-Sync Replicas&#xff09;是Kafka保證數據一致性的核心機制&#xff0c;由Leader副本&#xff08;復雜讀寫&#xff09;和Follower副本(負責備份)組成。當Follower副本的延遲超過replica.lag.time.max.ms&#…

Docker 基本概念與安裝指南

Docker 基本概念與安裝指南 一、Docker 核心概念 1. 容器&#xff08;Container&#xff09; 容器是 Docker 的核心運行單元&#xff0c;本質是一個輕量級的沙盒環境。它基于鏡像創建&#xff0c;包含應用程序及其運行所需的依賴&#xff08;如代碼、庫、環境變量等&#xf…

數據庫監控 | MongoDB監控全解析

PART 01 MongoDB&#xff1a;靈活、可擴展的文檔數據庫 MongoDB作為一款開源的NoSQL數據庫&#xff0c;憑借其靈活的數據模型&#xff08;基于BSON的文檔存儲&#xff09;、水平擴展能力&#xff08;分片集群&#xff09;和高可用性&#xff08;副本集架構&#xff09;&#x…

OpenFeign和Gateway

OpenFeign和Gateway 一.OpenFeign介紹二.快速上手1.引入依賴2.開啟openfeign的功能3.編寫客戶端4.修改遠程調用代碼5.測試 三.OpenFeign參數傳遞1.傳遞單個參數2.多個參數、傳遞對象和傳遞JSON字符串3.最佳方式寫代碼繼承的方式抽取的方式 四.部署OpenFeign五.統一服務入口-Gat…

spark-streaming(二)

DStream創建&#xff08;kafka數據源&#xff09; 1.在idea中的 pom.xml 中添加依賴 <dependency><groupId>org.apache.spark</groupId><artifactId>spark-streaming-kafka-0-10_2.12</artifactId><version>3.0.0</version> </…

JAVA聚焦OutOfMemoryError 異常

個人主頁 文章專欄 在正文開始前&#xff0c;我想多說幾句&#xff0c;也就是吐苦水吧…最近這段時間一直想寫點東西&#xff0c;停下來反思思考一下。 心中萬言&#xff0c;真正執筆時又不知先寫些什么。通常這個時候&#xff0c;我都會隨便寫寫&#xff0c;文風極像散文&…

如何在Spring Boot中配置自定義端口運行應用程序

Spring Boot 應用程序默認在端口 8080 上運行嵌入式 Web 服務器&#xff08;如 Tomcat、Jetty 或 Undertow&#xff09;。然而&#xff0c;在開發、測試或生產環境中&#xff0c;開發者可能需要將應用程序配置為在自定義端口上運行&#xff0c;例如避免端口沖突、適配微服務架構…

linux嵌入式(進程與線程1)

Linux進程 進程介紹 1. 進程的基本概念 定義&#xff1a;進程是程序的一次執行過程&#xff0c;擁有獨立的地址空間、資源&#xff08;如內存、文件描述符&#xff09;和唯一的進程 ID&#xff08;PID&#xff09;。 組成&#xff1a; 代碼段&#xff1a;程序的指令。 數據…

智馭未來:NVIDIA自動駕駛安全白皮書與實驗室創新實踐深度解析

一、引言&#xff1a;自動駕駛安全的范式革新 在當今數字化浪潮的推動下&#xff0c;全球自動駕駛技術正大步邁入商業化的深水區。隨著越來越多的自動駕駛車輛走上道路&#xff0c;其安全性已成為整個行業乃至社會關注的核心命題。在這個關鍵的轉折點上&#xff0c;NVIDIA 憑借…

多模態大模型 Qwen2.5-VL 的學習之旅

Qwen-VL 是阿里云研發的大規模視覺語言模型&#xff08;Large Vision Language Model, LVLM&#xff09;。Qwen-VL 可以以圖像、文本、檢測框作為輸入&#xff0c;并以文本和檢測框作為輸出。Qwen-VL 系列模型性能強大&#xff0c;具備多語言對話、多圖交錯對話等能力&#xff…

Redis 與 Memcache 全面對比:功能、性能與應用場景解析

Redis 和 Memcache 都是常用的內存數據庫&#xff0c;以下是它們在多個方面的能力比較&#xff1a; 一、數據類型 Redis&#xff1a;支持豐富的數據類型&#xff0c;如字符串&#xff08;String&#xff09;、哈希&#xff08;Hash&#xff09;、列表&#xff08;List&#x…

Oracle--PL/SQL編程

前言&#xff1a;本博客僅作記錄學習使用&#xff0c;部分圖片出自網絡&#xff0c;如有侵犯您的權益&#xff0c;請聯系刪除 PL/SQL&#xff08;Procedural Language/SQL&#xff09;是Oracle數據庫中的一種過程化編程語言&#xff0c;構建于SQL之上&#xff0c;允許編寫包含S…

新增優惠券

文章目錄 概要整體架構流程技術細節小結 概要 接口分析 一個基本的新增接口&#xff0c;按照Restful風格設計即可&#xff0c;關鍵是請求參數。之前表分析時已經詳細介紹過這個頁面及其中的字段&#xff0c;這里不再贅述。 需要特別注意的是&#xff0c;如果優惠券限定了使…

力扣面試經典150題(第二十三題)- KMP算法

問題 給你兩個字符串 haystack 和 needle &#xff0c;請你在 haystack 字符串中找出 needle 字符串的第一個匹配項的下標&#xff08;下標從 0 開始&#xff09;。如果 needle 不是 haystack 的一部分&#xff0c;則返回 -1 。 示例 1&#xff1a; 輸入&#xff1a;haysta…