在 Linux 跑 Docker 要對 Apache 的 Log 做 logrotate,會遇到 Apache 沒有 reload 的問題
- 註:會看到 logrotate 有執行,但是 Log 檔持續寫 access.log.1,若 Apache reload 成功,應該要寫 access.log
個人筆記, 記錄關於 系統、程式、新聞 與 日常生活 等資訊
在 Linux 跑 Docker 要對 Apache 的 Log 做 logrotate,會遇到 Apache 沒有 reload 的問題
Apache 的 Access log 一般都是以秒為單位,開啟詳細的 Log 格式為下述:
官方說明:Log Files - Apache HTTP Server Version 2.4
[10/Oct/2000:13:55:36 -0700] (%t) The time that the request was received. The format is:
[day/month/year:hour:minute:second zone]
day = 2digit
month = 3letter
year = 4digit
hour = 2digit
minute = 2digit
second = 2digit
zone = (`+' | `-') 4digit
想要將精確度到毫秒、微秒等級,要怎麼做呢?
Apache2 的 MPM 設定有 prefork、worker 的模式,現在新版還有 event 模式,此篇的參數雖然寫 prefork,不過 worker 的設定值也大同小異~
註:此篇只看 prefork
升級 Apache2 套件看到的訊息:
apache2 (2.4.25-3+deb9u5) stretch; urgency=medium
* This package upgrades mod_http2 to the version from apache2 2.4.33. This fixes a lot of bugs and some security issues, but it also removes the support for using HTTP/2 when running with mpm_prefork. HTTP/2 support is only provided when running with mpm_event or mpm_worker.
-- Stefan Fritsch <sf@debian.org> Sat, 02 Jun 2018 09:51:46 +0200
2.4.33 之後,mod_http2 不支援 mpm_prefork,只有支援 mpm_event 和 mpm_worker,詳細內容可見:
Apache 使用 mod_rewrite 可以設定轉址,但是轉址一直沒有朝自己想的設定方向走,要怎麼 Debug 呢?
Apache2 前面加上 Load Balancer (F5 Big IP LTM),走得就類似 Reverse Proxy 的模式,會由 F5 將 X-Forwarded-For 轉送到 Apache,要怎麼設定格式才能跟原始 combined 一樣呢?
Apache2 在 apache2ctl status 看到 G 的狀態,這些 process 都已經無法回應了,可以寫隻 script 來砍掉。
註:砍掉只是治標,建議還是看看這些 pid,研究看看卡在哪裡,治本才是重點。
PHP 的 urlencode 有兩種:
平常使用 urlencode() / rawurlencode() 在 Apache rewrite 轉回來都不會有問題,但是從其它程式語言來得,有遇到同時有 %20 和 +,但是這些在 Apache 端都會被轉成空白讓 PHP 吃,該怎麼避免 + 被轉成空白呢?
現在可以執行的 Daemon 太多了, PHP、Python、Ruby、Node.js、Go... 等等, 都會想要拿來跑 Web service,但是 80 Port 只有一個,所以前面只好擋一層 Apache 來達成。
於是使用 Apache 的 Proxy 功能來將後面各種服務的 Port 接上。