1.安装nginx,注意不要安装nginx-common或者nginx-full

sudo apt-get install nginx
sudo apt-get install nginx-common
sudo apt-get install nginx-extras

确认版本

apt list --installed | grep nginx

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

nginx/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1.10.3-0ubuntu0.16.04.4 all [已安装]
nginx-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1.10.3-0ubuntu0.16.04.4 all [已安装]
nginx-extras/xenial-updates,xenial-security,now 1.10.3-0ubuntu0.16.04.4 amd64 [已安装]

2.修改配置 /etc/nginx/nginx.conf

http {

        ##
# Basic Settings
## sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off; # server_names_hash_bucket_size 64;
# server_name_in_redirect off; include /etc/nginx/mime.types;
default_type application/octet-stream; ##
# SSL Settings
## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on; ##
# Logging Settings
## # access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log; ##
# Gzip Settings
## gzip on;
gzip_disable "msie6"; # gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; ##
# Virtual Host Configs
## include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
} log_format access_json '{"ts":"$fmt_localtime",'
'"schema":"com.xxx.xxx",'
'"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; map $host $fmt_localtime {
default '';
} log_by_lua_block {
ngx.var.fmt_localtime = ngx.localtime();
} }

3.输出的日志

{"ts":"2019-10-13 22:59:48","schema":"com.xxx.xxx","host":"127.0.0.1","clientip":"127.0.0.1","size":0,"responsetime":0.000,"upstreamtime":"-","upstreamhost":"-","http_host":"localhost","url":"/index.html","domain":"localhost","xff":"-","referer":"-","status":"304"}
{"ts":"2019-10-13 22:59:48","schema":"com.xxx.xxx","host":"127.0.0.1","clientip":"127.0.0.1","size":0,"responsetime":0.000,"upstreamtime":"-","upstreamhost":"-","http_host":"localhost","url":"/index.html","domain":"localhost","xff":"-","referer":"-","status":"304"}
												

Nginx修改时间戳的更多相关文章

  1. Nginx 修改用户权限

    [1]Nginx 修改用户权限 (1)修改前:Nginx系统默认用户权限是nobody 查看可知: (2)修改方法 欲使用root权限启动的. 修改 /usr/local/nginx/conf/ 下n ...

  2. Nginx修改配置实现图片防盗链

    一般情况下,防盗链是针对软件下载和图片的,由于一般的站点不提供资源下载,所以本文主要是针对图片的防盗链 1.如果对全站图片做防盗链,至少需要一个另外的域名存放指向图片.因为如果对全站图片做了防盗链,包 ...

  3. linux下修改时间戳

    Linux下touch是一个非常有用的命令. touch语法结构如下: touch [-acfm][-d <日期时间>][-r <参考文件或目录>][-t <日期时间&g ...

  4. Nginx修改access.log日志时间格式

    一.修改原因 因为要获取nginx访问信息,作为开发的数据使用,但是nginx的access.log文件中的默认的时间格式是这样的: [02/Nov/2017:20:48:25 +0800] 而要求的 ...

  5. 创建文件和修改时间戳——touch

    linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件. 1.命令格式: touch [选项]... 文件... 2.命令参数: -a    ...

  6. nginx修改nginx.conf配置可以https访问

    修改nginx.conf,参照如下更改配置server { listen 443; server_name abc.com; // 访问域名 ssl on; root /var/www/bjubi.c ...

  7. Nginx修改版本信息或隐藏版本号

    一,隐藏版本号.首先说明,这个是某一方面隐藏,不是彻底隐藏.未隐藏之前查看nginx信息: 隐藏方法: 修改nginx.conf配置文件,在http { } 标签里边加入字段: server_toke ...

  8. nginx 修改文件上传大小限制

    修改nginx的配置文件,添加client_max_body_size 字段 注:client_max_body_size 必须要放在server下的server_name下,而不是放在locatio ...

  9. nginx修改响应头(可屏蔽后端服务器的信息:IIS,PHP等)

    修改nginx反向代理请求的Header 需要使用到proxy_set_header和add_header指令.其中: proxy_set_header 来自内置模块ngx_http_proxy_mo ...

随机推荐

  1. nginx+Gunicorn部署你的Flask项目

    https://www.cnblogs.com/minsons/articles/8191219.html 大家在学习python的时候常常都是输入 python 文件名.py 这样启动小脚本 但实际 ...

  2. ANDROID - 打包和引用本地的AAR

        打包方法: 打开Gradle面板 Gradle Projects: 选择Library对应的Gradle Task,比如:":testsdk": 依次 Tasks > ...

  3. java5-11各个版本新特性

    转载:https://blog.csdn.net/zl1zl2zl3/article/details/85055948 Java 5 Java5开发代号为Tiger(老虎),于2004-09-30发行 ...

  4. IMP本质上是一个通用的函数指针

    IMP:通用的函数指针 /// A pointer to the function of a method implementation. #if !OBJC_OLD_DISPATCH_PROTOTY ...

  5. Reincarnation HDU - 4622 (后缀自动机)

    Reincarnation \[ Time Limit: 3000 ms\quad Memory Limit: 65536 kB \] 题意 给出一个字符串 \(S\),然后给出 \(m\) 次查询, ...

  6. 洛谷 P1731 [NOI1999]生日蛋糕 题解

    每日一题 day53 打卡 Analysis 观察一个蛋糕的俯视图,上表面的面积其实就是最下面那一层的底面积,所以在第一次搜索的时候加入这个底面积,之后就只用考虑侧面积就好啦. 就是每次枚举r和h,如 ...

  7. luogu_3645: 雅加达的摩天楼

    雅加达的摩天楼 题意描述: 有\(N\)座摩天楼,从左到右依次编号为\(0\)到\(N-1\). 有\(M\)个信息传递员,编号依次为\(0\)到\(M-1\).编号为i的传递员最初在编号为\(B_i ...

  8. cortex 基本试用

    cortext是prometheus的多租户解决方案,目前在cncf 沙箱孵化,以下是一个简单的试用 注意因为golang 包的问题,而且以下依赖的几个项目都是基于go module 的所以使用了go ...

  9. 6.学习springmvc的文件上传

    一.文件上传前提与原理分析 1.文件上传必要前提: 2.文件上传原理分析: 3.需要引入的jar包: 二.传统方式文件上传程序 1.pom.xml <dependency> <gro ...

  10. 52: Luogu 4777 excrt

    模板题 #include <bits/stdc++.h> using namespace std; ; #define LL long long int n; LL a[N], m[N]; ...