导读 最近实时的项目有个需求,就是要查看集群中各个节点下面跑的项目的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://blog.csdn.net/weixin_35852328/article/details/81181353

本文地址:https://www.linuxprobe.com/nginx-access-directory.html编辑:王华超,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/

Linux系统大全:https://www.linuxdown.com/

红帽认证RHCE考试心得:https://www.rhce.net/