Legacy API Access Log

這份文件記錄所有 legacy API migration 共用的正式機 access log 位置、rotation 命名、查詢方式,以及各次候選 API 流量盤點結果。單支 API 的 business rule 應寫在對應 module inventory 或 detail doc,不放在這裡。

2026-07-14 查詢環境

項目
hostmei-te@ip-10-5-2-242
log directory/var/log/apache2
access log basenameget-lancer_access.log
查詢範圍所有 get-lancer_access.log*,包含 uncompressed 與 gzip rotations
觀察到的檔名get-lancer_access.logget-lancer_access.log.1get-lancer_access.log-YYYYMMDDget-lancer_access.log.N.gzget-lancer_access.log-YYYYMMDD.gz

當次 find 結果觀察到的 access-log file mtime 約從 2026-05-29 到 2026-07-14;mtime 只用來描述保留檔案範圍,不等同逐筆 request timestamp 已完整驗證。

Log 位置查找

不要直接執行:

sudo ls -lh /var/log/apache2/*access.log*

shell 會在執行 sudo 前展開 wildcard;目前帳號無法列目錄時,可能把未展開的 literal path 傳給 sudo ls,因此即使檔案存在仍看到 No such file or directory

固定改用:

sudo find /var/log -maxdepth 4 -type f \
  \( -iname '*access*' -o -iname '*get-lancer*' \) \
  -ls 2>/dev/null | head -100

查單一路徑

uncompressed 與 gzip 要分開,避免漏掉 -YYYYMMDD.N.gz rotation:

{
  sudo find /var/log/apache2 -maxdepth 1 -type f \
    -name 'get-lancer_access.log*' ! -name '*.gz' \
    -exec grep -hF '/users/activation/' {} +
 
  sudo find /var/log/apache2 -maxdepth 1 -type f \
    -name 'get-lancer_access.log*.gz' \
    -exec zgrep -hF '/users/activation/' {} +
} | wc -l

2026-07-14 查 /users/activation/ 結果為 0,因此 GET /users/activation/{user_id}/{hash}.json 暫不列下一支 migration 候選。

查多個候選路徑

曾嘗試把長 ERE 分成多行複製,換行落在 | 附近後出現 grep: Unmatched ( or \(。為避免 shell / terminal 貼上換行破壞 regex,固定使用 fixed-string array:

terms=(
  '/users/dashboard'
  '/users/view'
  '/users/register'
  '/users/iphone_social_register'
  '/users/logout'
  '/users/skills'
  '/users/credentials'
  '/users/integration_data'
  '/users/intercom_data'
  '/users/refer_from_api'
  '/users/verify'
  '/users/sign_in'
  '/user_profiles/edit'
  '/user_profiles/profile_image'
  '/user_referrals/remove_referee'
  '/quote_bids/recent_quotes'
  '/quote_bids/rating'
  '/quote_bids/save_review'
  '/quote_bids/process_after_hired'
  '/quote_activities/activities'
)
 
grep_args=()
for term in "${terms[@]}"; do
  grep_args+=(-e "$term")
done
 
{
  sudo find /var/log/apache2 -maxdepth 1 -type f \
    -name 'get-lancer_access.log*' ! -name '*.gz' \
    -exec grep -hF "${grep_args[@]}" {} +
 
  sudo find /var/log/apache2 -maxdepth 1 -type f \
    -name 'get-lancer_access.log*.gz' \
    -exec zgrep -hF "${grep_args[@]}" {} +
} | awk '{method=$6; gsub(/"/, "", method); path=$7; sub(/\?.*/, "", path); print method, path, $9}' \
  | sort | uniq -c | sort -nr

注意:fixed-string candidate scan 會讓 /users/logout 命中 /admin/users/logout/user_profiles/edit 命中 /admin/user_profiles/edit/...。判斷 migration 流量時要排除 admin / HTML path,不能直接把所有命中相加。

2026-07-14 Users 候選流量結果

2026-07-14 對全部保留的 get-lancer_access.log* 查詢:

EndpointMethodstatuscount
/users/verify/phone/auth.jsonPOST20021,760
/users/verify/phone/auth.jsonOPTIONS20011,469
/users/verify/phone/auth.jsonPOST40331
/users/verify/phone/preauth.jsonPOST20021,715
/users/verify/phone/preauth.jsonOPTIONS20011,810
/users/verify/phone/preauth.jsonPOST40380
/users/verify/voice/preauth.jsonPOST200207
/users/verify/voice/preauth.jsonOPTIONS200137
/users/verify/email/preauth.jsonPOST2002

同次另看到各 1 筆舊 path:

  • POST /users/verify_phone/preauth.json 200
  • POST /users/verify_phone.json 200
  • POST /users/verify_email.json 200

判讀:

  • phone/preauthphone/auth 都有約 2.1 萬筆成功 POST,且 OPTIONS 量相近,是下一批 Users migration 第一優先。
  • voice/preauth 有明確正式流量,排在 phone lifecycle 之後。
  • email/preauth legacy 流量極低,且 current web-app 已改走 /new/v1/email_verifications/preauth*;先確認 replacement,不和 phone flow 一起搬。

其他候選結果

Path結果判讀
/users/activation/{user_id}/{hash}.json0暫緩搬移
/users/dashboard13 GET 302HTML / redirect,不是本次 JSON migration
/users/view/{id}.json3 GET 2001 HEAD 200極低流量,先確認是否探測 / 人工請求
/users/sign_in2 GET 403非成功 JSON 主流程,不列優先
/user_profiles/edit/{hash}1 GET 200路徑不是 inventory 中的 POST /user_profiles/edit.json,需另查 caller
/quote_bids/recent_quotes.json1 GET 200極低流量;current web-app caller 已註解,不列優先

/admin/users/logout/admin/user_profiles/edit/... 是 fixed-string scan 的 admin 命中,已排除,不算前台 API 流量。