gateway nginx實現前後端動靜分離

2021-10-24 08:40:53 字數 1062 閱讀 1321

gateway閘道器:

1.通過路徑匹配

#商品服務

- id: product_route

uri: lb://gulimail-product

predicates:

- path=/api/product/**,/hello

filters:

- rewritepath=/api/(?.*),/$\

2.通過host網域名稱匹配

#通過host**到商品系統

- id: gulimail_host_route

uri: lb://gulimail-product #表示負載均衡到gulimail-product服務

predicates:

- host=gulimail.com

#通過host**到search系統

- id: gulimail_search_route

uri: lb://gulimail-search #表示負載均衡到gulimail-search服務

predicates:

- host=search.gulimail.com

動靜分離:

nginx直接**給閘道器,閘道器判斷:

如果是/api/****,直接轉交給對應的伺服器(在本專案中,該路徑僅是資料互動的介面)————動

如果是滿足網域名稱,轉交給對應的服務(給前端返回對應服務的index.html頁面)———動

對應的伺服器給前端瀏覽器返回index.html頁面後,對頁面進行初始化,然後從nginx裡面拿靜態資料例如、js、css檔案等———靜

前 和後 的實現

前置 type operator 後置 const type operator int 為了編譯器區分前置和後置 c 規定字尾形式有乙個int型別引數 當函式被呼叫時,編譯器傳遞乙個0做為int引數的值給該函式。不這樣規定,無法區分,因為都僅以自身物件為入參。下面是乙個簡單的例子 class cin...

遞迴實現前向匹配分詞

coding utf 8 功能 遞迴實現前向匹配分詞 說明 zhuanma這個包借鑑自jieba分詞源 用於 將任意格式編碼的字串轉換為unicode編碼,統一 字典和待分詞語句的編碼後,便於句子切分和分詞.author date 2016 04 16 import re from zhuanma ...

最短路的前向星實現

include include include include include include include include using namespace std const int maxn 1000 const int maxm maxn maxn const int inf 0x3f3f3...