Quantcast

Nginx log rotation

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Nginx log rotation

Paolo Aglialoro
Hi misc!

Considering that with 5.2 nginx is going to be (already is?) the official
http server (I'm using it with joy, I like its minimalistic approach), is
there some officially recommended way to rotate the logs in /var/www/logs/
which are getting bigger and bigger?

Btw, as apache is still present in faq, is any man nginx.conf / faq entry
planned or the only nginx.org is THE doc resource?

Thanks

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nginx log rotation

Antoine Jacoutot-7
On Wed, Dec 26, 2012 at 11:02:56PM +0100, Paolo Aglialoro wrote:
> Hi misc!
>
> Considering that with 5.2 nginx is going to be (already is?) the official
> http server (I'm using it with joy, I like its minimalistic approach), is
> there some officially recommended way to rotate the logs in /var/www/logs/
> which are getting bigger and bigger?

Just use newsyslog(8) and send SIGUSR1 to /var/run/nginx.pid.


> Btw, as apache is still present in faq, is any man nginx.conf / faq entry
> planned or the only nginx.org is THE doc resource?
>
> Thanks
>

--
Antoine

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nginx log rotation

Nick Holland
In reply to this post by Paolo Aglialoro
On 12/26/12 17:02, Paolo Aglialoro wrote:
...
> Btw, as apache is still present in faq, is any man nginx.conf / faq entry
> planned or the only nginx.org is THE doc resource?
>
> Thanks
>

The reason for FAQ entries about things like Apache/httpd being chrooted
is that it isn't standard in the "main" Apache distribution (STILL...but
that's another rant), and creates an unexpected surprise for OpenBSD
users.  So, we document it.

An alert about the nginx default chrooting would definitely be in order.
 Other things?  Not sure.  I just lit up nginx on one of my systems to
replace the apache-derived httpd, and it was pretty darned simple, so
we'll have to see if OpenBSD-specific Questions end up being Frequently
Asked...but I have no desire for OpenBSD.org to become a primary source
of information about generic nginx usage.

Nick.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nginx log rotation

Paolo Aglialoro
In reply to this post by Antoine Jacoutot-7
Thank you, here is the diff for newsyslog.conf:


1c1
< #     $OpenBSD: newsyslog.conf,v 1.29 2011/04/14 20:32:34 sthen Exp $
---
> #     $OpenBSD: newsyslog.conf,v 1.30 2012/12/27 02:16:14 sthen Exp $
17a18,19
> #/var/www/logs/access.log             644  7     *    24    ZB "kill -s
USR1 `cat /var/run/nginx.pid`"
> #/var/www/logs/error.log              644  7     *    24    ZB "kill -s
USR1 `cat /var/run/nginx.pid`"


On Wed, Dec 26, 2012 at 11:49 PM, Antoine Jacoutot <[hidden email]>wrote:

> On Wed, Dec 26, 2012 at 11:02:56PM +0100, Paolo Aglialoro wrote:
> > Hi misc!
> >
> > Considering that with 5.2 nginx is going to be (already is?) the official
> > http server (I'm using it with joy, I like its minimalistic approach), is
> > there some officially recommended way to rotate the logs in
> /var/www/logs/
> > which are getting bigger and bigger?
>
> Just use newsyslog(8) and send SIGUSR1 to /var/run/nginx.pid.
>
>
> > Btw, as apache is still present in faq, is any man nginx.conf / faq entry
> > planned or the only nginx.org is THE doc resource?
> >
> > Thanks
> >
>
> --
> Antoine

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nginx log rotation

Michał Markowski
2012/12/27 Paolo Aglialoro <[hidden email]>:
>> #/var/www/logs/access.log             644  7     *    24    ZB "kill -s
> USR1 `cat /var/run/nginx.pid`"
>> #/var/www/logs/error.log              644  7     *    24    ZB "kill -s
> USR1 `cat /var/run/nginx.pid`"
>

Why B flag and global read permissions?



--
Michał Markowski

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nginx log rotation

Paolo Aglialoro
B flag to avoid newsyslog manipulating contents of log files, like it
happens for pflog

644 was just for being comfortable (it comes from a 1 user system), it may
of course be changed to be stricter


On Thu, Dec 27, 2012 at 2:35 AM, Michał Markowski
<[hidden email]>wrote:

> 2012/12/27 Paolo Aglialoro <[hidden email]>:
> >> #/var/www/logs/access.log             644  7     *    24    ZB "kill -s
> > USR1 `cat /var/run/nginx.pid`"
> >> #/var/www/logs/error.log              644  7     *    24    ZB "kill -s
> > USR1 `cat /var/run/nginx.pid`"
> >
>
> Why B flag and global read permissions?
>
>
>
> --
> Michał Markowski

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nginx log rotation

Michał Markowski
2012/12/27 Paolo Aglialoro <[hidden email]>:
> B flag to avoid newsyslog manipulating contents of log files, like it
> happens for pflog

Yep, but /var/log/pflog is binary, contrary to nginx logs.

> 644 was just for being comfortable (it comes from a 1 user system), it may
> of course be changed to be stricter

So you are probably in wheel group already and 640 should be
comfortable enough. :)

--
Michał Markowski

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nginx log rotation

Antoine Jacoutot-7
In reply to this post by Paolo Aglialoro
On Thu, Dec 27, 2012 at 02:22:46AM +0100, Paolo Aglialoro wrote:

> Thank you, here is the diff for newsyslog.conf:
>
>
> 1c1
> < #     $OpenBSD: newsyslog.conf,v 1.29 2011/04/14 20:32:34 sthen Exp $
> ---
> > #     $OpenBSD: newsyslog.conf,v 1.30 2012/12/27 02:16:14 sthen Exp $
> 17a18,19
> > #/var/www/logs/access.log             644  7     *    24    ZB "kill -s
> USR1 `cat /var/run/nginx.pid`"
> > #/var/www/logs/error.log              644  7     *    24    ZB "kill -s
> USR1 `cat /var/run/nginx.pid`"

Remove "B".
And the last part should be:
/var/run/nginx.pid SIGUSR1

e.g.
/var/www/logs/access.log 644 7     *    24    Z /var/run/nginx.pid SIGUSR1


> On Wed, Dec 26, 2012 at 11:49 PM, Antoine Jacoutot <[hidden email]>wrote:
>
> > On Wed, Dec 26, 2012 at 11:02:56PM +0100, Paolo Aglialoro wrote:
> > > Hi misc!
> > >
> > > Considering that with 5.2 nginx is going to be (already is?) the official
> > > http server (I'm using it with joy, I like its minimalistic approach), is
> > > there some officially recommended way to rotate the logs in
> > /var/www/logs/
> > > which are getting bigger and bigger?
> >
> > Just use newsyslog(8) and send SIGUSR1 to /var/run/nginx.pid.
> >
> >
> > > Btw, as apache is still present in faq, is any man nginx.conf / faq entry
> > > planned or the only nginx.org is THE doc resource?
> > >
> > > Thanks
> > >
> >
> > --
> > Antoine
>

--
Antoine

Loading...