{"id":19317669,"url":"https://github.com/queeniecplusplus/nginx_backend","last_synced_at":"2026-03-19T09:15:32.889Z","repository":{"id":104588370,"uuid":"298165990","full_name":"QueenieCplusplus/Nginx_Backend","owner":"QueenieCplusplus","description":"後端伺服器  Web Server","archived":false,"fork":false,"pushed_at":"2020-09-24T05:33:58.000Z","size":720,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T04:44:39.803Z","etag":null,"topics":["backend-as-a-service","backend-server","rewrite","rewrite-system"],"latest_commit_sha":null,"homepage":"https://github.com/QueenieCplusplus/QuickGoThru/blob/master/README.md#nginx--k8s-in-2020","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QueenieCplusplus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-24T04:10:38.000Z","updated_at":"2023-08-04T05:25:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"7cd35e50-6fb9-4df4-827f-c3cd59e10751","html_url":"https://github.com/QueenieCplusplus/Nginx_Backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/QueenieCplusplus/Nginx_Backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FNginx_Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FNginx_Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FNginx_Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FNginx_Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QueenieCplusplus","download_url":"https://codeload.github.com/QueenieCplusplus/Nginx_Backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FNginx_Backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29889510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T08:34:21.514Z","status":"ssl_error","status_checked_at":"2026-02-27T08:32:38.035Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend-as-a-service","backend-server","rewrite","rewrite-system"],"created_at":"2024-11-10T01:15:48.161Z","updated_at":"2026-02-27T09:38:35.954Z","avatar_url":"https://github.com/QueenieCplusplus.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nginx_Backend\n後端伺服器\n\n\n       upstream qs_backend{\n       \n          ip_hash;\n          \n          server katesbackend.com;\n          server pattysbackend.com;\n       \n       }\n\n\n* upstream 指令\n\n   將被代理伺服器集中成為一群組，方便管理。\n\n* ip_hash 指令（實現連現階段的保持）\n\n   跟輪詢搭配加權相對應的方式，當有此指令時，表示代理伺服器會依據（記憶）該使用者之 IP 位址，\n   從而進行工作分配之任務，保障了使用者與特定伺服器的連線處於穩定狀態，倘若此指令為 down 關閉狀態，\n   則使用者請求可能會被（輪詢後）下一個後端伺服器服務。\n\n------------------------\n\n* Domain Name Jump 域名跳躍\n\n  涉及 url 重定義。\n\n* Mirroring  域名鏡像 (CDN)\n\n  ![mirror](https://raw.githubusercontent.com/QueenieCplusplus/Nginx_Backend/master/mirror-server.png)\n  \n  \n              server{\n\n                  listen 80;\n                  server_name m1.katesapp2021.com\n                  #需追加域名跳躍\n\n\n              }\n\n              server{\n\n                  listen 81;\n                  server_name m2.katesapp2021.com\n                  #需追加域名跳躍\n\n              }\n\n  相同網站 LB 到多台伺服器上，並分別使用獨立的域名，其中一個為主站 Primary Server，其它為鏡像網站 Mirror Server。\n  主站與鏡像網站沒有區別，故具有備援功能。\n  \n  此技術可以解決網路流量過大和緩解單一和少數伺服器的請求處理壓力（加強異地回應速度），並且因為鏡像網站能儲存網頁和歷史資料，\n  可以防止資料遺失。\n\n------------------------\n\n* URL Redefine 位址重定義（產生多次網路請求）\n\n  不同的位址中，選擇正確的位址。\n  例如使用者對網址 google.cn 發出請求，伺服器判斷為 www.google.com （完整路徑名稱）的過程。\n  當然，此過程後段會產生位址重新導向的階段發生。\n\n* URL Redirect 位址轉發（僅發出一次網路請求）\n\n  作用發生於同一網站專案內部，\n  將域名指向到一個已經存在的網站的過程。\n  \n------------------------\n\n* keepalive [connections] 指令\n\n   該指令可控制網路聯結數量，保障代理伺服器的工作處理程序為後端伺服器群組開放的使用者端網路連接，為其數量做一定控管，\n   與 worker_connections 有反相關，後者為單一工作處理程序與用戶端(使用者端)連接的最大上限數。\n   \n   \n\n                            Moduel  |  Data |  File\n                            ________|_______|_________\n                            Registry|       |  Stack\n                            \n                            \n                                       ||                   Master Process\n                                                         /       |         \\\n                                                           （實現平行處理）\n                                                     /           |            \\\n                         worker threads | slave process   slave process   slave process      全域：設定允許產生的工作處理程序的數量\n                         \n                                             /||\\               /||\\             /||\\         \n                                            / || \\             / || \\           / || \\       事件：connections 單一工作程序能處理的最大連接數設定  65535  \n                                           /  ||  \\           /  ||   \\        /  ||  \\    \n                                           \n                                        ｜｜｜｜｜｜｜ ｜｜｜｜｜｜  ｜｜｜｜｜｜ ｜｜｜｜｜｜ ｜｜   Http: 單連接請求上限數為 100                             \n\n\n   \n   Keepalive connections can have a major impact on performance by reducing the CPU and network overhead needed to close connections.\n       \n   NGINX terminates all client（user-side） connections and creates separate and independent connections to the upstream servers. \n\n   NGINX supports keepalives for both clients and upstream servers. \n\n    * keepalive_requests – \n      \n      The number of requests a client can make over a single keepalive connection. \n      The default is 100, but a much higher value can be especially useful for testing with a load‑generation tool, which generally sends a large number of requests from a single client.\n\n    * keepalive_timeout – \n       How long an idle keepalive connection remains open.\n       \n     ![keepalive](https://raw.githubusercontent.com/QueenieCplusplus/Nginx_Backend/master/keep-alive.png)\n\n    * keepalive – (relates to upstream keepalives)\n      \n      The number of idle keepalive connections to an upstream server that remain open for each worker process. \n\n\n\n\n\n* least_conn 指令\n\n  依據權重，選擇最少（網路）連接（數量）的伺服器。\n\n------------------------\n\n* 複寫規則（與覆寫相同，有防盜連功能）\n\n  應用範圍廣泛，例如位址重定義、一級域名跳耀、多級域名跳耀、為單一網站專案下子目錄資源做鏡像處理。\n  對安全也能做一層『防盜連』處理。\n\n\n# 實作範例\n\n https://blog.dtask.idv.tw/Nginx/2018-07-31/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueeniecplusplus%2Fnginx_backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqueeniecplusplus%2Fnginx_backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueeniecplusplus%2Fnginx_backend/lists"}