This is a nginx configuration
server {
listen $PORT;
location ~ ^/documents/(.*)$ {
proxy_pass http://127.0.0.1:5000/$1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location = /favicon.ico {
return 204;
access_log off;
log_not_found off;
}
}
There are two use cases of the url /documents/
:
POST to /documents/
for some processing or
GET to /documents/ping
used by AWS ELB as health check
In cloudwatch log I got heap of pings entries as a result
What is the easiest way to ask nginx not to log the ping?
Here's an easy way - add this location block.
There are probably cleaner ways. One is to define the shared contents of the two blocks as a file and include it, but for a one-off I wouldn't bother.
Note - don't use if statements unless you can't help it.
Update
If you want to do an include do something like this
In the file fragment.conf
Agree that the ~ wasn't necessary, but I don't think it would hurt either.