mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-11-03 19:58:14 +00:00 
			
		
		
		
	Added detailled logging for nginx
This commit is contained in:
		@@ -1,9 +1,22 @@
 | 
				
			|||||||
# role nginx
 | 
					# role nginx
 | 
				
			||||||
 | 
					This role sets up an nginx server. It was developed by [Kevin Veen-Birkenbach](https://www.veen.world).
 | 
				
			||||||
 | 
					## Debug
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## debug
 | 
					### General Debugging
 | 
				
			||||||
```bash 
 | 
					```bash 
 | 
				
			||||||
journalctl -f -u nginx
 | 
					journalctl -f -u nginx
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Detailled Debugging
 | 
				
			||||||
 | 
					Set ``enable_debugenable_debug: true``.
 | 
				
			||||||
 | 
					#### Follow logs of one host
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					journalctl -u nginx -f | grep "<<hostname>>"
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Activate detailled Debugging:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## performance
 | 
					## performance
 | 
				
			||||||
- https://www.monitis.com/blog/6-best-practices-for-optimizing-your-nginx-performance/
 | 
					- https://www.monitis.com/blog/6-best-practices-for-optimizing-your-nginx-performance/
 | 
				
			||||||
- https://www.nginx.com/blog/tuning-nginx/
 | 
					- https://www.nginx.com/blog/tuning-nginx/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,8 +17,22 @@ http
 | 
				
			|||||||
  # caching
 | 
					  # caching
 | 
				
			||||||
  proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:20m max_size=20g inactive=14d use_temp_path=off;
 | 
					  proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:20m max_size=20g inactive=14d use_temp_path=off;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # logs
 | 
					  # logging and debugging
 | 
				
			||||||
 | 
					{% if enable_debug | bool %}
 | 
				
			||||||
 | 
					  # individual log format for better debugging
 | 
				
			||||||
 | 
					  log_format debug '$host - $remote_addr [$time_local] '
 | 
				
			||||||
 | 
					                  '"$request" $status $body_bytes_sent '
 | 
				
			||||||
 | 
					                  '"Referer: $http_referer" '
 | 
				
			||||||
 | 
					                  '"User-Agent: $http_user_agent" '
 | 
				
			||||||
 | 
					                  '"ReqTime: $request_time" "UpstreamTime: $upstream_response_time" '
 | 
				
			||||||
 | 
					                  '"ReqLength: $request_length" "BytesSent: $bytes_sent" '
 | 
				
			||||||
 | 
					                  '"ConnRequests: $connection_requests" '
 | 
				
			||||||
 | 
					                  '"X-Forwarded-For: $http_x_forwarded_for" '
 | 
				
			||||||
 | 
					                  '"Scheme: $scheme" "Protocol: $server_protocol" "ServerName: $server_name"';
 | 
				
			||||||
 | 
					  access_log syslog:server=unix:/dev/log debug;
 | 
				
			||||||
 | 
					{% else %}
 | 
				
			||||||
  access_log syslog:server=unix:/dev/log;
 | 
					  access_log syslog:server=unix:/dev/log;
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
  error_log syslog:server=unix:/dev/log;
 | 
					  error_log syslog:server=unix:/dev/log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sendfile on;
 | 
					  sendfile on;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user