#user nobody;
user root;
worker_processes 1;
error_log /spdblogs/nginx/logs/error.log;
error_log /spdblogs/nginx/logs/notice.log notice;
error_log /spdblogs/nginx/logs/info.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
server_tokens off;
include mime.types;
default_type application/octet-stream;
client_max_body_size 10m;
map $time\_iso8601 $logdate {
'~^(?<ymd>\\d{4}-\\d{2}-\\d{2})' $ymd;
default 'date-not-found';
}
#过滤lua循环的日志
map $http\_user\_agent $normal {
~^lua-resty-http 0;
default 1;
}
#log\_format main '$remote\_addr - $remote\_user \[$time\_local\] "$request" '
# '$status $body\_bytes\_sent "$http\_referer" '
# '"$http\_user\_agent" "$http\_x\_forwarded\_for"';
log\_format main '{"@timestamp":"$time\_iso8601",'
'"host":"$server\_addr",'
'"clientip":"$remote\_addr",'
'"size":$body\_bytes\_sent,'
'"request\_time":$request\_time,'
'"upstreamhost":"$upstream\_addr",'
'"http\_host":"$host",'
'"url":"$request\_uri",'
'"domain":"$host",'
'"http\_x\_forwarded\_for":"$http\_x\_forwarded\_for",'
'"referer":"$http\_referer",'
'"http\_user\_agent":"$http\_user\_agent",'
'"request":"$request",'
'"status":"$status"}';
access\_log /logs/nginx/logs/access-$logdate.log main if=$normal;
#error\_log /logs/nginx/logs/error-$2.log;
#error\_log /logs/nginx/logs/notice-$2.log notice;
#error\_log /logs/nginx/logs/info-$2.log info;
sendfile on;
#tcp\_nopush on;
#keepalive\_timeout 0;
keepalive\_timeout 65;
#gzip on;
upstream icar {
#server 192.168.0.91:9001 max\_fails=5;
server 192.168.0.81:9001 max\_fails=5;
server 192.168.0.118:9001 max\_fails=5;
keepalive 400;
}
upstream icarimg {
server 192.168.0.91:9018;
server 192.168.0.81:9018;
}
server {
listen 80;
server\_name localhost;
#charset koi8-r;
#access\_log logs/host.access.log main;
proxy\_set\_header X-Real-IP $remote\_addr;
proxy\_set\_header X-Forwarded-For $remote\_addr;
#proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;
proxy\_set\_header Host $host;
add\_header 'Access-Control-Allow-Origin' '\*';
add\_header 'Access-Control-Allow-Headers' '\*';
add\_header 'Access-Control-Allow-Methods' '\*';
}
}
如果是error的话,就写个定时服务去cp ,然后 /usr/local/nginx/sbin/nginx -s reload
不然的话就要去修改源码了。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章