阅读背景:

ELK之收集Nginx、Tomcat的json格式日志

来源:互联网 

1.安装Nginx

yum -y install nginx
vim /etc/nginx/nginx.conf
# 修改日志格式为json格式,并创建一个nginxweb的网站目录
log_format access_json '{"@timestamp":"$time_iso8601",'
                           '"host":"$server_addr",'
                           '"clientip":"$remote_addr",'
                           '"size":$body_bytes_sent,'
                           '"responsetime":$request_time,'
                           '"upstreamtime":"$upstream_response_time",'
                           '"upstreamhost":"$upstream_addr",'
                           '"http_host":"$host",'
                           '"url":"$uri",'
                           '"domain":"$host",'
                           '"xff":"$http_x_forwarded_for",'
                           '"referer":"$http_referer",'
                           '"status":"$status"}';
access_log  /var/log/nginx/access.log  access_json;
vim /etc/nginx/conf.d/nginxweb.conf
server {
    listen       80;
    server_name  10.0.0.22;

    location /nginxweb {
        root html;
        index index.html index.htm;
    }
    error_page  404              /404.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

mkdir /usr/share/nginx/html/nginxweb
echo "<h1> welcome to use Nginx" </h1> /usr/share/nginx/html/nginxweb/index.html
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
systemctl start nginx
# 访问https://10.0.0.22/nginxweb/时一直报404,查了一下,发现/etc/nginx/下没有静态文件
ln -s /usr/share/nginx/html/ /etc/nginx/
yum -y install nginx
vim /etc/n



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: