Fix(logger): Ignore docker health check requests
This patch disables logging of HTTP requests containing health-check UA from the local IP address. These logs can take up a lot of disk space but are of little use. Signed-off-by: Chongyun Lee <uchkks@protonmail.com>
This commit is contained in:
		
							parent
							
								
									abbf36741a
								
							
						
					
					
						commit
						a852d66f01
					
				
							
								
								
									
										6
									
								
								app.js
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								app.js
									
									
									
									
									
								
							| @ -63,8 +63,14 @@ if (!config.useSSL && config.protocolUseSSL) { | |||||||
|   app.set('trust proxy', 1) |   app.set('trust proxy', 1) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // check if the request is from container healthcheck
 | ||||||
|  | function isContainerHealthCheck (req, _) { | ||||||
|  |   return req.headers['user-agent'] === 'hedgedoc-container-healthcheck/1.0' && req.ip === '127.0.0.1' | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // logger
 | // logger
 | ||||||
| app.use(morgan('combined', { | app.use(morgan('combined', { | ||||||
|  |   skip: isContainerHealthCheck, | ||||||
|   stream: logger.stream |   stream: logger.stream | ||||||
| })) | })) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user