Legacy API Access Log
這份文件記錄所有 legacy API migration 共用的正式機 access log 位置、rotation 命名、查詢方式,以及各次候選 API 流量盤點結果。單支 API 的 business rule 應寫在對應 module inventory 或 detail doc,不放在這裡。
2026-07-14 查詢環境
| 項目 | 值 |
|---|---|
| host | mei-te@ip-10-5-2-242 |
| log directory | /var/log/apache2 |
| access log basename | get-lancer_access.log |
| 查詢範圍 | 所有 get-lancer_access.log*,包含 uncompressed 與 gzip rotations |
| 觀察到的檔名 | get-lancer_access.log、get-lancer_access.log.1、get-lancer_access.log-YYYYMMDD、get-lancer_access.log.N.gz、get-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 -l2026-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* 查詢:
| Endpoint | Method | status | count |
|---|---|---|---|
/users/verify/phone/auth.json | POST | 200 | 21,760 |
/users/verify/phone/auth.json | OPTIONS | 200 | 11,469 |
/users/verify/phone/auth.json | POST | 403 | 31 |
/users/verify/phone/preauth.json | POST | 200 | 21,715 |
/users/verify/phone/preauth.json | OPTIONS | 200 | 11,810 |
/users/verify/phone/preauth.json | POST | 403 | 80 |
/users/verify/voice/preauth.json | POST | 200 | 207 |
/users/verify/voice/preauth.json | OPTIONS | 200 | 137 |
/users/verify/email/preauth.json | POST | 200 | 2 |
同次另看到各 1 筆舊 path:
POST /users/verify_phone/preauth.json200POST /users/verify_phone.json200POST /users/verify_email.json200
判讀:
phone/preauth與phone/auth都有約 2.1 萬筆成功 POST,且 OPTIONS 量相近,是下一批 Users migration 第一優先。voice/preauth有明確正式流量,排在 phone lifecycle 之後。email/preauthlegacy 流量極低,且 current web-app 已改走/new/v1/email_verifications/preauth*;先確認 replacement,不和 phone flow 一起搬。
其他候選結果
| Path | 結果 | 判讀 |
|---|---|---|
/users/activation/{user_id}/{hash}.json | 0 | 暫緩搬移 |
/users/dashboard | 13 GET 302 | HTML / redirect,不是本次 JSON migration |
/users/view/{id}.json | 3 GET 200、1 HEAD 200 | 極低流量,先確認是否探測 / 人工請求 |
/users/sign_in | 2 GET 403 | 非成功 JSON 主流程,不列優先 |
/user_profiles/edit/{hash} | 1 GET 200 | 路徑不是 inventory 中的 POST /user_profiles/edit.json,需另查 caller |
/quote_bids/recent_quotes.json | 1 GET 200 | 極低流量;current web-app caller 已註解,不列優先 |
/admin/users/logout 與 /admin/user_profiles/edit/... 是 fixed-string scan 的 admin 命中,已排除,不算前台 API 流量。