在實際環境中測試
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
A負載均衡器是現代 IT 基礎設施中的重要組成部分,旨在有效地在多個伺服器或資源之間分配網路流量。 這可以防止任何單一伺服器過載,從而提高系統的可擴展性和性能。 負載平衡器位於客戶端與後端伺服器之間,能夠在使用可用資源的同時最大限度地減少響應時間。
負載均衡器執行這些基本任務,包括容錯、流量分配和會話持久性。 負載均衡器可以是主要的軟體程序、實體產品或由 AWS 或 Azure 提供的雲端服務。 一些最常用的流量分配算法是循環法、最少連接法和IP哈希法。
HAProxy Docker指將 HAProxy 負載均衡器放置在 Docker 容器中。 HAProxy 的流量管理功能現在可以與 Docker 的靈活性和可攜性相結合。 HAProxy 是一款受歡迎且廣泛使用的開源負載均衡器,適用於提供高可用性和反向代理的網頁應用程式和微服務環境。 在 Docker 容器主機中運行 HAProxy 的優點包括簡易部署、隔離性、可擴展性和平台獨立性。 HAProxy Docker 能有效地將流量分配到多個後端服務,監控容器的健康狀況,並根據容器的可用性動態調整路由。
損壞的圖片 從Pixabay添加,從你的文件中選擇或拖放圖片到這裡。
它支持的功能包括SSL/TLS終止、會話持久性以及多種負載平衡算法,包括輪詢和最少連接。 這使得 HAProxy Docker 成為管理容器化流量的絕佳方式,因為它甚至可以很好地與像 Kubernetes 或 Docker Swarm 這樣的編排工具集成,以提供動態擴展和自動化服務發現。 這確保了現代應用程式具備穩健、高效能和安全的流量管理,同時不會有任何檔案問題。
HAProxy 在將網路流量負載分配到多個後端伺服器方面表現出色。 其眾多的負載平衡算法包括循環調度、最少連接和IP哈希,從而使客戶能夠根據其應用程式的特殊需求調整流量。 這使得HAProxy可以在第4層接受流量(TCP)和第七層(HTTP/HTTPS)支援的架構,讓它在從簡單的 TCP 路由應用程式到複雜的應用層負載平衡方面都具有高效能範圍。
其核心功能,高可用性,意指保持服務持續運行。 HAProxy 根據後端伺服器的健康狀態,將流量從被證明不健康或故障的伺服器中轉移開。 故障切換可防止在伺服器不運行或意外故障的情況下遭遇過多停機時間。
HAProxy 完全支持 SSL/TLS,確保從客戶端到伺服器的安全通信。 此外,HAProxy 可以終止 SSL/TLS 連接,以分擔後端伺服器的加密和解密任務,從而提高前者的性能。 如果需要端到端加密,HAProxy 可以將加密流量轉發到其後的服務。
HAProxy 是最佳的反向代理之一,用於將所有客戶端請求流量發送到後端的相關服務。它支持的功能包括修改標頭、從 URL 重定向,甚至基於特定用戶條件的專門路由,這些條件可以根據特定規則設置。 因此,HAProxy 也可以被認為是多服務架構的可行方案之一,與微服務一起。
HAProxy 具有完整的安全功能,例如速率限制、DDoS 保護和 ACL。 所有這些都用於過濾進入的流量,這意味著可能會到達後端伺服器的惡意請求將被攔截,以保持您的應用穩定。
HAProxy 具有高度的可擴展性。 它可以輕鬆支援數百萬個並發連接而不會產生延遲,並隨著擴展而無延遲問題。 此環境支援如 Kubernetes 和 Docker Swarm 的容器編排環境,其容器化工作負載提供動態擴展和服務發現的優勢。
HAProxy 具有精細的日誌記錄功能,可幫助理解流量、排除問題並分析性能。 它可以無縫地與 Prometheus 的監控工具、Grafana 和 Datadog 等其他工具進行互操作,並呈現有關伺服器健康狀況、網路流量與資源使用的即時數據。
HAProxy 提供非常靈活且強大的配置功能。 利用此功能,使用者可以設定相當複雜的路由規則,例如根據標頭或 cookie 條件進行路由。 支持URL重寫以及會話持久性,甚至還支持多租戶架構,這意味著一個HAProxy實例可以服務多個域或應用程式。
使用 Docker 安裝和運行 HAProxy 是一個相當簡單的過程。 以下是逐步採取的步驟。
確保在您的系統上安裝了 Docker。 要驗證安裝,你可以運行以下命令:
docker --version
docker --version
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker --version
如果系統上未安裝 Docker,請訪問Docker 連結此處下載並從官方網站安裝。
從 Docker Hub 拉取官方 HAProxy 映像。 最新版本的HAProxy將下載最新穩定版本:
docker pull haproxy:latest
docker pull haproxy:latest
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker pull haproxy:latest
HAProxy 需要一個配置文件來定義其行為。 下載 Docker 和 HAProxy 的相應 Dockerfile 連結後,創建一個名為 haproxy.cfg 的文件,內容如下範例:
global
log stdout format raw local0
defaults
log global
mode http
timeout connect 5s
timeout client 50s
timeout server 50s
frontend http_front
bind *:80
default_backend http_back
backend http_back
server app1 host.docker.internal:32769 check
global
log stdout format raw local0
defaults
log global
mode http
timeout connect 5s
timeout client 50s
timeout server 50s
frontend http_front
bind *:80
default_backend http_back
backend http_back
server app1 host.docker.internal:32769 check
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'global log stdout format raw local0 defaults log global mode http timeout connect 5s timeout client 50s timeout server 50s frontend http_front bind *:80 default_backend http_back backend http_back server app1 host.docker.internal:32769 check
此 HAProxy 配置定義:
前端:監聽 4500 埠並將流量路由到後端
後端:在兩台伺服器之間分配流量,即 app1
運行 HAProxy Docker 容器,掛載配置檔並開放必要的埠:
docker run -d --network haproxy --name haproxy-container -p 4500:4500 -v D:\Docker\haproxy-config\haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro haproxy:latest
docker run -d --network haproxy --name haproxy-container -p 4500:4500 -v D:\Docker\haproxy-config\haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro haproxy:latest
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker run -d --network haproxy --name haproxy-container -p 4500:4500 -v D:\Docker\haproxy-config\haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro haproxy:latest
-d: 運行容器的分離模式。
將主機上的端口4500映射到容器中的端口4500。
打開網路瀏覽器,然後導航到 http://localhost:4500 或您的伺服器 IP 位址來測試流量路由。
要檢查 HAProxy 的統計資訊,請運行以下命令:
IronSecureDoc是一個用於文件管理和安全性的工具,依靠強加密、高級 PDF 操作和數位簽名。 它為公司和開發人員提供文件的保密性和完整性,從而使 PDF 文件的處理更簡便,且無需直接或間接的依賴。 這也可以在其功能使開發人員能夠以程式化方式創建、上傳、操作和保護 PDF 文件和文檔的情況下稱為 Aggressive PDF API。
此外,IronPDF 是一個 PDF API,可以從任何數據輸入創建 PDF,並使用如文字、圖片和元數據等參數添加或編輯內容。 這包括合併多個 PDF 文件以製作組合文件、拆分文件,甚至用於註釋的評論、突出顯示或浮水印。
它提供密碼保護、AES 加密和基於證書的訪問控制,從而鎖定所有敏感信息和數據。 除此之外,它還具備數位簽署功能,用於驗證您的文件並防止否認——這在金融、醫療和法律行業中是非常重要的功能。 其審計追蹤功能允許監控文件上執行的所有活動,以增強合規性和問責性。
使用命令提示字元或開啟的終端窗口,根據以下倉庫拉取IronSecureDoc的Docker映像。
docker pull ironsoftwareofficial/ironsecuredoc
docker pull ironsoftwareofficial/ironsecuredoc
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker pull ironsoftwareofficial/ironsecuredoc
IronSecureDoc,運行容器。IronSecureDoc,運行容器。
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
上面的 Docker run 指令將啟動 IronSecureDoc 的容器實例。 現在,您可以通過以下頁面訪問 IronSecureDoc,網址為 http://localhost:8080/swagger/index.html。
準備一個 haproxy.cfg 檔案來定義您的前端和後端配置。 以下是一個簡單的配置範例:
explain below haproxy.cfg file
global
log stdout format raw local0
defaults
log global
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http_front
bind *:4500
acl body_has_data req.hdr_val(Content-Length) gt 0
http-request set-method POST if METH_GET body_has_data
use_backend ironsecuredoc if { path /ironsecuredoc }
{ path_beg /ironsecuredoc/ }
use_backend ironsecuredoc_ping if { path /ping }
{ path_beg /ping/ }
use_backend ironsecuredoc_encrypt if { path /encrypt }
{ path_beg /encrypt/ }
#default_backend ironsecuredoc
backend ironsecuredoc
balance roundrobin
http-request set-path /swagger/index.html
server ironsecuredoc_server3 host.docker.internal:8080 check
backend ironsecuredoc_encrypt
balance roundrobin
http-request set-path /v1/document-services/pdfs/encrypt
server ironsecuredoc_server3 host.docker.internal:8080 check
backend ironsecuredoc_ping
balance roundrobin
http-request set-path /v1/document-services/ping
server ironsecuredoc_server3 host.docker.internal:8080 check
explain below haproxy.cfg file
global
log stdout format raw local0
defaults
log global
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http_front
bind *:4500
acl body_has_data req.hdr_val(Content-Length) gt 0
http-request set-method POST if METH_GET body_has_data
use_backend ironsecuredoc if { path /ironsecuredoc }
{ path_beg /ironsecuredoc/ }
use_backend ironsecuredoc_ping if { path /ping }
{ path_beg /ping/ }
use_backend ironsecuredoc_encrypt if { path /encrypt }
{ path_beg /encrypt/ }
#default_backend ironsecuredoc
backend ironsecuredoc
balance roundrobin
http-request set-path /swagger/index.html
server ironsecuredoc_server3 host.docker.internal:8080 check
backend ironsecuredoc_encrypt
balance roundrobin
http-request set-path /v1/document-services/pdfs/encrypt
server ironsecuredoc_server3 host.docker.internal:8080 check
backend ironsecuredoc_ping
balance roundrobin
http-request set-path /v1/document-services/ping
server ironsecuredoc_server3 host.docker.internal:8080 check
explain below haproxy.cfg file global log stdout format raw local0 defaults log global mode http [option] httplog timeout connect 5000Ds timeout client 50000Ds timeout server 50000Ds frontend http_front bind *:4500 acl Function req_hdr_val(Content- ByVal Length As ) As body_has_data Implements req.hdr_val
'INSTANT VB TODO TASK: Local functions are not converted by Instant VB:
' path /ironsecuredoc }
' {
' path_beg /ironsecuredoc/
' }
'INSTANT VB TODO TASK: Local functions are not converted by Instant VB:
' use_backend ironsecuredoc_ping if
' {
' path /ping }
' {
' path_beg /ping/
' }
' use_backend ironsecuredoc_encrypt if
' {
' path /encrypt }
' {
' #default_backend ironsecuredoc
' path_beg /encrypt/
' }
''INSTANT VB TODO TASK: The following line uses invalid syntax:
'' backend ironsecuredoc balance roundrobin http-request @set-path /swagger/index.html server ironsecuredoc_server3 host.docker.internal:8080 check backend ironsecuredoc_encrypt balance roundrobin http-request @set-path /v1/document-services/pdfs/encrypt server ironsecuredoc_server3 host.docker.internal:8080 check backend ironsecuredoc_ping balance roundrobin http-request @set-path /v1/document-services/ping server ironsecuredoc_server3 host.docker.internal:8080 check
此 HAProxy 配置文件創建了一個能夠處理多個 IronSecureDoc 服務的 HTTP 流量的系統。 然後,將全域配置為將原始日誌輸出到標準輸出,並且默認區段啟用 HTTP 作為模式和詳細的 HTTP,並設置用戶端和服務器的連接超時。 前端是定義在 4500 端口的 http_front,包含根據 HTTP 請求路徑管理路由的規則。例如,對 /ironsecuredoc 的請求被路由到 ironsecuredoc 後端。 對 /ping 和 /encrypt 的請求會路由到各自的後端。 ACL 规则通过 Content-Length 标头识别有主体的请求。 如果體存在,它會將 GET 請求轉換為 POST。
循環演算法用於在後端之間分配流量。 每個後端在將請求轉發到相應的伺服器之前,會重寫請求路徑。 例如,ironsecuredoc 後端將路徑重寫為 /swagger/index.html。 ironsecuredoc_encrypt 和 ironsecuredoc_ping 後端分別將路徑重寫為 /v1/document-services/pdfs/encrypt 和 /v1/document-services/ping。 他們全部指向在 host.docker.internal:8080 運行的一台伺服器。已新增健康檢查以確保伺服器可用。 因此,配置確保了各種服務的流量管理順暢,同時在請求的操作上具有靈活性。
curl -X 'POST' \
'http://localhost:4500/encrypt?user_password=demo' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'pdf_file=@test.pdf;type=application/pdf'
curl -X 'POST' \
'http://localhost:4500/encrypt?user_password=demo' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'pdf_file=@test.pdf;type=application/pdf'
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'curl -X 'POST' \ 'http: -H 'accept: */ *' \ -H 'Content-Type: multipart/form-data' \ -F 'pdf_file=@test.pdf;type=application/pdf'
但是如果我們正在發佈到IronSecureDoc API,我們也可能希望要求以使用者的密碼加密請求的密碼至文件。 文件輸出檔案將會自動發送並下載,並將安全保存。
它還將集成包含的HAProxy與IronSecureDoc軟體,以確保在管理文件安全的服務時,提供可靠且可擴展的解決方案,並優化流量路由和負載平衡。 由於通過實施健康檢查來處理故障轉移,以及提供針對不同服務端點的自訂路由規則,從而將流量有效地分配到多個 IronSecureDoc 實例中,高可用性得到了保證。
此配置支援靈活處理如加密和健康監控等複雜工作流程,同時在未來具有可擴展性。 無論是在容器化環境還是傳統環境中,HAProxy 的輕量且高效能設計非常適合作為 IronSecureDoc 的安全功能互補,提供可靠且高效的安全文件管理。 HAProxy 的功能協助組織在部屬 IronSecureDoc 時改善應用程式的性能與彈性。
使用 IronSecureDoc REST API,安全列印和高效的 PDF 格式處理現在可以輕鬆地整合到由網頁、行動設備和企業系統開發人員開發的應用程式中。 如需進一步了解 IronSecureDoc 的許可證,請造訪授權頁面. 有關Iron Software產品的資訊,請參閱程式庫套件頁面.
10 .NET API 產品 針對您的辦公文件