blacklabelops-legacy / nginx

Dockerized Ready-To-Go Nginx Reverse Proxy. Let's encrypt Support!
MIT License
95 stars 41 forks source link

Docker Volumes ["/home/nginx","/var/log/nginx"] needed? #19

Closed JannikZed closed 7 years ago

JannikZed commented 7 years ago

Hi, I'm using your excellent nginx as an reverse proxy for our micro-services architecture. I was just wondering, what the Volumes ["/home/nginx","/var/log/nginx"] are good for? As they are mandatory, we need to add them @ our hosting provider and are no longer stateless - thus can not scale easily. So my question is, are they really needed?

blacklabelops commented 7 years ago

Hello Jannik,

Nginx writes an error logfile. I wasn't able to suppress that. The file error.log is written in /var/log/nginx. Messages are also written in stdout but still messages are also persisted inside logfiles. It's bad practise to have log files outside volume therefore the volume.

There is also a seed file for ssl communication, see the configuration at ssl_dhparam /home/nginx/dhparam.pem;. It's very costly to generate this file and takes about one minute. Therefore the volume /var/log/nginx to keep the file. This can can be ignored as long as you do not use the https features of this image.

Hope that answered your questions!

JannikZed commented 7 years ago

Hi, Thank you, that helps! I was trying by my own, to stop nginx from logging - but it's really strange, he won't stop :D But is that really a problem? I mean he can log if he wants to, but that doesn't has to be a stateful docker volume, does it? What can possibly go wrong, if I just don't add this Volume?

I see, that you think it's relevant to have persistent volumes. That's your decision, so I think we might close this issue. I just forked your absolute nice work and removed the volumes, as we really need the proxy stateless, otherwise we can't scale.

Thank you :)

blacklabelops commented 7 years ago

Hi Jannik,

Nginx still logs because the first log message is written before the configuration is read. So there will be no problem removing that volume. The second volume is not that easy, if I remove the home directory and do not write the ssl seed inside a volume by default then my container will have a start time of several minutes. Are you even using https?

All in all I think it should be no problem if nginx write one dummy file. In my view it's still stateless or does your server suppress any file operations?

blacklabelops commented 7 years ago

Hello Jannik,

I am testing a volume free version of my image on the development branch. The image is available under the tag development, e.g. docker run ... blacklabelops/nginx:development.

Please test the image and give feedback if it fits your demands.

JannikZed commented 7 years ago

Hi, We are using a german docker-hosting provider that is called "https://sloppy.io". They are offering an integrated loadbalancer with HTTPS-offloading and let's encrypt support. Our Nginx proxies just need to forward correctly to our micro-services. For containers without persistent volumes they are offering a simple scaling-feature. You just tell them how many containers you want - and you are good to go. The sloppy loadbalancer is forwarding the traffic round-robin to our nginx-containers. That's the reason, why I asked for a nginx without volumes. In other environments you might not even notice it ..

Thank you thank you thank you for the development container!! I'm trying it out right now!! :)