Difference between revisions of "Nginx.conf"

From wikieduonline
Jump to navigation Jump to search
(Redirected page to /etc/nginx/nginx.conf)
Tag: New redirect
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
#redirect [[/etc/nginx/nginx.conf]]
* Error log file: <code>/var/log/nginx/error.log</code>
 
* Access log file: <code>/var/log/nginx/access.log</code>
 
 
 
 
 
==Directives ==
 
 
server_name YOUR_DOMAIN.COM;
 
root /var/www/your_domain;
 
 
 
:<code>listen</code><ref>http://nginx.org/en/docs/http/ngx_http_core_module.html#listen</ref>
 
::<code>listen 443 ssl;</code>
 
::<code>listen 80 ssl;</code>
 
 
 
:<code>try_files $uri $uri/ @rewrite;</code>
 
 
 
:<code>[[fastcgi_pass]]</code> (Used for [[PHP]])
 
 
 
:<code>[[rewrite]]</code>
 
 
 
 
 
:<code>[[location]]</code>
 
 
 
:<code>worker_processes auto;</code>
 
:<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>
 
:<code>tcp_nopush on;</code>
 
:<code>tcp_nodelay on;</code>
 
 
 
 
 
:<code>server_tokens off;</code> (in http context)
 
 
 
[[Proxy]] (Nginx can proxy requests using http, [[FastCGI]], uwsgi, SCGI, or memcached.)
 
:<code>proxy_read_timeout 2400s;</code>
 
:<code>proxy_connect_timeout 75s;</code>
 
:<code>proxy_send_timeout 2400s;</code>
 
:<code>proxy_buffer_size 32k;</code>
 
:<code>proxy_buffers 40 32k;</code>
 
:<code>proxy_busy_buffers_size 64k;</code>
 
:<code>proxy_temp_file_write_size 250m;</code>
 
:<code>proxy_http_version 1.1;</code>
 
 
 
[[SSL]]
 
: <code>ssl_certificate      /etc/nginx/ssl/example.pem;</code>
 
: <code>ssl_certificate_key  /etc/nginx/ssl/example.key;</code>
 
: <code>ssl_protocols TLSv1 TLSv1.1 TLSv1.2;</code>
 
: <code>ssl_prefer_server_ciphers on;</code>
 
 
 
== Track Application Response time in Nginx <ref>https://lincolnloop.com/blog/tracking-application-response-time-nginx/</ref> ==
 
 
 
1) Add to <code>/etc/nginx/nginx.conf</code>
 
 
 
http://nginx.org/en/docs/http/ngx_http_log_module.html
 
<pre>
 
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';
 
</pre>
 
:::<code>$pipe</code> “p” if request was [[pipelined]], “.” otherwise
 
:::<code>$request_time</code>
 
:::<code>$upstream_response_time</code>
 
 
 
2) Modify access_log directive to use new format:
 
<pre>
 
access_log /var/log/nginx/yourdomain.com.access.log timed_combined;
 
</pre><ref>https://stackoverflow.com/a/39260524</ref>
 
 
 
:<code>request_time</code> This shows how long Nginx dealt with the request
 
:<code>upstream_response_time</code> Gives us the time it took our upstream server (in this case Apache/mod_wsgi) to respond
 
:<code>pipe</code> Shows ‘p’ in case the request was pipelined.
 
 
 
== See also ==
 
* {{nginx}}
 
* [[Apache web server]]
 
* [[Reverse proxy]]
 
 
 
[[Category:Web server software]]
 

Latest revision as of 10:50, 3 March 2021

Advertising: