I tried adding the following to a my_proxy.conf
file that gets mounted into /etc/nginx/conf.d/
in the container as described in https://github.com/jwilder/nginx-proxy#custom-nginx-configuration but the logs aren't making into logstash.
Initially I added this to the conf file:
http {
# Custom log format that also includes the host that processed the request
log_format logstash '$remote_addr - $remote_user [$time_local] "$host" '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
# Send logs to Logstash
access_log syslog:server=logstash:5140,tag=nginx_access logstash;
error_log syslog:server=logstash:5140,tag=nginx_error notice;
}
but when I start the container it tells me "http" directive is not allowed here in /etc/nginx/conf.d/my_proxy.conf:11
So now I just have
# Custom log format that also includes the host that processed the request
log_format logstash '$remote_addr - $remote_user [$time_local] "$host" '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
# Send logs to Logstash
access_log syslog:server=logstash:5140,tag=nginx_access logstash;
error_log syslog:server=logstash:5140,tag=nginx_error notice;
which doesn't get any complaints when starting nginx, but doesn't put anything into logstash either. From here I don't know how to troubleshoot.
Syslog doesn't run in your container, so it doesn't make sense to use it for logging. Your options:
1.) Configure gelf
logging driver on the Docker daemon level:
Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
Doc: https://docs.docker.com/config/containers/logging/configure/
2.) Start/configure dedicated logging container, which will send data for selected container(s) to logstash. See Logspout
or other similar tools.