Print access logs to console rather than a file
Proposed changes
Since this Nginx configuration is meant to be used as a Router running as a container in OpenShift, access logs should be printed to the console log in order to be accessible from the console and collected with Elastic. It will also prevent the local container storage from running full.
Checklist
- [x] I have read the CONTRIBUTING guide
- [x] I have proven my fix is effective or that my feature works
- [ ] I have updated necessary documentation
- [x] I have rebased my branch onto master
- [x] I will ensure my PR is targeting the master branch and pulling from my branch on my own fork
Hi @tux-o-matic
Thanks for you time and this PR!
A couple of things. This router was done the same way the official Openshift router. They use logging to a file, that's why we did it this way.
However, this project is going to be deprecated soon in favour of using the Kubernetes Ingress Controller in Openshift. Since Openshift 4.X, Red Hat doesn't allow to use any other router (NGINX, F5 Big IP..) than the official HAProxy one, that's why we are going to support only the Kubernetes Ingress Controller in the future and stop supporting the Router.
Because of this, we can't accept this PR as this project is going to be deprecated soon. However, if you would like to achieve this, I recommend you to use this other approach instead, maybe is easier?
Adding these links in the Dockerfile before building your Router image will send all the logs to the container std output instead of a file.
RUN ln -sf /proc/1/fd/1 /var/log/nginx/access.log \
&& ln -sf /proc/1/fd/1 /var/log/nginx/stream-access.log \
&& ln -sf /proc/1/fd/2 /var/log/nginx/error.log
Thanks and sorry for any inconvenience