Difference between revisions of "Nginx.conf"

From wikieduonline
Jump to navigation Jump to search
Line 6: Line 6:
 
==Directives ==
 
==Directives ==
 
<code>sendfile on;</code><ref>https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/#enabling-sendfile</ref>
 
<code>sendfile on;</code><ref>https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/#enabling-sendfile</ref>
 +
<code>include /etc/nginx/mime.types;</code>
  
 
== Track Application Response time in Nginx <ref>https://lincolnloop.com/blog/tracking-application-response-time-nginx/</ref> ==
 
== Track Application Response time in Nginx <ref>https://lincolnloop.com/blog/tracking-application-response-time-nginx/</ref> ==

Revision as of 09:12, 26 December 2019

  • Error log file: /var/log/nginx/error.log
  • Access log file: /var/log/nginx/access.log


Directives

sendfile on;[1] include /etc/nginx/mime.types;

Track Application Response time in Nginx [2]

1) Add to /etc/nginx/nginx.conf

http://nginx.org/en/docs/http/ngx_http_log_module.html

log_format timed_combined '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent" '
    '$request_time $upstream_response_time $pipe';
$pipe “p” if request was pipelined, “.” otherwise
$request_time
$upstream_response_time

2) Modify access_log directive to use new format:

access_log /var/log/nginx/yourdomain.com.access.log timed_combined;

[3]

request_time This shows how long Nginx dealt with the request
upstream_response_time Gives us the time it took our upstream server (in this case Apache/mod_wsgi) to respond
pipe Shows ‘p’ in case the request was pipelined.

See also

  • https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/#enabling-sendfile
  • https://lincolnloop.com/blog/tracking-application-response-time-nginx/
  • https://stackoverflow.com/a/39260524
  • Advertising: