this is about what I learned about open resty and nginx
-- Sam 14:45 13/08/2020

 为什么要用Token
  1. 用用户名和密码不安全,被劫持了的话,黑客就能用来随时登陆系统干坏事了。而token的话,也就是这一次干干坏事,而不是天天干坏事。这一点上token和sessionId是一样的。
  2. 用户和密码通常不放在内容中,为了不被黑客看到。而是加密后放在数据库里面。
  3. token的话,每次生成的是不一样的,虽然用户和密码一样,但是因为日渐不同,所以生成额token不会相同。
-- Sam 19:25 12/01/2023
 the lua will not ignore the second condition?
I saw many code like:
function _M.init()
    if _M.tgpAdsDictIsEmpty() and updateWithLock() == false then
        ngx.sleep(1)
        return _M.init()
    end
end
so, if the 
_M.tgpAdsDictIsEmpty() is false, the second condition 
updateWithLock() == false
will still be called, right? 
-- Sam 17:12 13/08/2020
  1. 在conf目錄下會有一個nginx.conf文件,裏面是關於nginx的配置。 (相當於tomcat相關的配置)
  2. 在conf目錄下,會有一個conf.d子文件夾,裏面會放各種openresty相關的配置文件。  (相當於應用相關的配置)
    1. 這裏可以通過include 來接入任何地方的.conf(配置)文件
      1. 例如include /home/web1/app/env/properties.conf;
      2. 這裏的路徑是發佈後的路徑,因爲畢竟這是脚本語言,所以沒有編譯過程,寫的就是最終執行時的樣子。
  3. 我記得所有用到的變量,都需要配置文件中先聲明。
  4. openresty的配置裏面有一票類似location ~ ^/frogs/([0-9]*)/?$ {的代碼塊,用來接受通過不同url發送過來的請求
    1. 裏面基本做法就是給一些變量膚質,
    2. 讓後調用一個controller作爲返回内容的生成器:content_by_lua_file /home/web1/app/lua/controller/v1-mapping-controller.lua;
      1. 每個controller裏面都是一個local function main() 方法,方法裏面是處理邏輯。
      2. 邏輯基本就是參數檢查+調用service類的方法
      3. 調用ngx的exec或者redirect方法生成要返回的内容。
-- Sam 15:07 13/08/2020

Please click here to login and add comments! || automatically refresh content every seconds