最近實時的項目有個需求,就是要查看集群中各個節點下面跑的項目的Log。於是想到了用Nginx將log目錄暴露出來集成到現有的監控平台中去。 nginx的安裝配置在前面的博客中有提到過,這里記錄下如何配置訪問log目錄。 |
1 首先,設置權限
配置需要訪問的log目錄有權限
chmod -R /.../...
在nginx.conf文件中,添加或覆蓋下面一行
user root;
2 配置server節點
server { listen 64001; server_name beta3.hadoop.feidai.com; charset utf-8; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; autoindex on; } location /feidai-kafka-kudu/bin/slog { root /root; autoindex on; } location /feidai-canal-kafka/bin/slog { root /root; autoindex on; } ......
其中添加了兩個location節點,配置autoindex on;使其能展示目錄。
在location節點里面配置alas會把指定路徑當作文件路徑,
而配置root會把指定路徑拼接到文件路徑后,再進行訪問。
這里使用root配置。
訪問實例:http://beta3.hadoop.feidai.com:64001/feidai-kafka-kudu/bin/slog/
整合到監控平台的效果如下圖
本文地址:https://www.linuxprobe.com/nginx-access-directory.html