File tree Expand file tree Collapse file tree 12 files changed +76
-18
lines changed Expand file tree Collapse file tree 12 files changed +76
-18
lines changed Original file line number Diff line number Diff line change @@ -201,9 +201,29 @@ const setupCertbotPlugins = () => {
201
201
} ) ;
202
202
} ;
203
203
204
+
205
+ /**
206
+ * Starts a timer to call run the logrotation binary every two days
207
+ * @returns {Promise }
208
+ */
209
+ const setupLogrotation = ( ) => {
210
+ const intervalTimeout = 1000 * 60 * 60 * 24 * 2 ; // 2 days
211
+
212
+ const runLogrotate = async ( ) => {
213
+ await utils . exec ( 'logrotate /etc/logrotate.d/nginx-proxy-manager' ) ;
214
+ logger . info ( 'Logrotate completed.' ) ;
215
+ } ;
216
+
217
+ logger . info ( 'Logrotate Timer initialized' ) ;
218
+ setInterval ( runLogrotate , intervalTimeout ) ;
219
+ // And do this now as well
220
+ return runLogrotate ( ) ;
221
+ } ;
222
+
204
223
module . exports = function ( ) {
205
224
return setupJwt ( )
206
225
. then ( setupDefaultUser )
207
226
. then ( setupDefaultSettings )
208
- . then ( setupCertbotPlugins ) ;
227
+ . then ( setupCertbotPlugins )
228
+ . then ( setupLogrotation ) ;
209
229
} ;
Original file line number Diff line number Diff line change 7
7
{% include "_hsts.conf" %}
8
8
{% include "_forced_ssl.conf" %}
9
9
10
- access_log /data/logs/dead_host-{{ id }}.log standard;
10
+ access_log /data/logs/dead-host-{{ id }}_access.log standard;
11
+ error_log /data/logs/dead-host-{{ id }}_error.log warn;
11
12
12
13
{{ advanced_config }}
13
14
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ server {
12
12
#listen [::]:80;
13
13
{% endif %}
14
14
server_name default-host.localhost;
15
- access_log /data/logs/default_host.log combined;
15
+ access_log /data/logs/default-host_access.log combined;
16
+ error_log /data/logs/default-host_error.log warn;
16
17
{% include "_exploits.conf" %}
17
18
18
19
{%- if value == "404" %}
Original file line number Diff line number Diff line change 8
8
9
9
server_name {{ domain_names | join: " " }};
10
10
11
- access_log /data/logs/letsencrypt-requests.log standard;
11
+ access_log /data/logs/letsencrypt-requests_access.log standard;
12
+ error_log /data/logs/letsencrypt-requests_error.log warn;
12
13
13
14
include conf.d/include/letsencrypt-acme-challenge.conf;
14
15
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ proxy_set_header Connection $http_connection;
19
19
proxy_http_version 1.1;
20
20
{% endif %}
21
21
22
-
23
- access_log /data/logs/proxy_host- {{ id }}.log proxy ;
22
+ access_log /data/logs/proxy-host-{{ id }}_access.log proxy;
23
+ error_log /data/logs/proxy-host- {{ id }}_error .log warn ;
24
24
25
25
{{ advanced_config }}
26
26
Original file line number Diff line number Diff line change 9
9
{% include "_hsts.conf" %}
10
10
{% include "_forced_ssl.conf" %}
11
11
12
- access_log /data/logs/redirection_host-{{ id }}.log standard;
12
+ access_log /data/logs/redirection-host-{{ id }}_access.log standard;
13
+ error_log /data/logs/redirection-host-{{ id }}_error.log warn;
13
14
14
15
{{ advanced_config }}
15
16
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ ENV SUPPRESS_NO_CONFIG_WARNING=1 \
20
20
21
21
RUN echo "fs.file-max = 65535" > /etc/sysctl.conf \
22
22
&& apt-get update \
23
- && apt-get install -y --no-install-recommends jq \
23
+ && apt-get install -y --no-install-recommends jq logrotate \
24
24
&& apt-get clean \
25
25
&& rm -rf /var/lib/apt/lists/*
26
26
@@ -43,6 +43,9 @@ COPY docker/rootfs /
43
43
# Remove frontend service not required for prod, dev nginx config as well
44
44
RUN rm -rf /etc/services.d/frontend /etc/nginx/conf.d/dev.conf
45
45
46
+ # Change permission of logrotate config file
47
+ RUN chmod 644 /etc/logrotate.d/nginx-proxy-manager
48
+
46
49
VOLUME [ "/data" , "/etc/letsencrypt" ]
47
50
ENTRYPOINT [ "/init" ]
48
51
HEALTHCHECK --interval=5s --timeout=3s CMD /bin/check-health
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ ENV S6_LOGGING=0 \
7
7
8
8
RUN echo "fs.file-max = 65535" > /etc/sysctl.conf \
9
9
&& apt-get update \
10
- && apt-get install -y certbot jq python3-pip \
10
+ && apt-get install -y certbot jq python3-pip logrotate \
11
11
&& apt-get clean \
12
12
&& rm -rf /var/lib/apt/lists/*
13
13
@@ -18,6 +18,7 @@ RUN cd /usr \
18
18
19
19
COPY rootfs /
20
20
RUN rm -f /etc/nginx/conf.d/production.conf
21
+ RUN chmod 644 /etc/logrotate.d/nginx-proxy-manager
21
22
22
23
# s6 overlay
23
24
RUN curl -L -o /tmp/s6-overlay-amd64.tar.gz "https://github.com/just-containers/s6-overlay/releases/download/v1.22.1.0/s6-overlay-amd64.tar.gz" \
Original file line number Diff line number Diff line change 1
1
# WARNING: This is a DEVELOPMENT docker-compose file, it should not be used for production.
2
- version : " 3"
2
+ version : " 3.5 "
3
3
services :
4
-
5
4
npm :
6
5
image : nginxproxymanager:dev
6
+ container_name : npm_core
7
7
build :
8
8
context : ./
9
9
dockerfile : ./dev/Dockerfile
@@ -36,6 +36,7 @@ services:
36
36
37
37
db :
38
38
image : jc21/mariadb-aria
39
+ container_name : npm_db
39
40
networks :
40
41
- nginx_proxy_manager
41
42
environment :
@@ -47,21 +48,26 @@ services:
47
48
- db_data:/var/lib/mysql
48
49
49
50
swagger :
50
- image : ' swaggerapi/swagger-ui:latest'
51
+ image : " swaggerapi/swagger-ui:latest"
52
+ container_name : npm_swagger
51
53
ports :
52
54
- 3001:80
53
55
networks :
54
56
- nginx_proxy_manager
55
57
environment :
56
58
URL : " http://127.0.0.1:3081/api/schema"
57
- PORT : ' 80 '
59
+ PORT : " 80 "
58
60
depends_on :
59
61
- npm
60
62
61
63
volumes :
62
64
npm_data :
65
+ name : npm_core_data
63
66
le_data :
67
+ name : npm_le_data
64
68
db_data :
69
+ name : npm_db_data
65
70
66
71
networks :
67
72
nginx_proxy_manager :
73
+ name : npm_network
Original file line number Diff line number Diff line change
1
+ /data/logs/*_access.log /data/logs/*/access.log {
2
+ create 0644 root root
3
+ weekly
4
+ rotate 4
5
+ missingok
6
+ notifempty
7
+ compress
8
+ sharedscripts
9
+ postrotate
10
+ /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
11
+ endscript
12
+ }
13
+
14
+ /data/logs/*_error.log /data/logs/*/error.log {
15
+ create 0644 root root
16
+ weekly
17
+ rotate 10
18
+ missingok
19
+ notifempty
20
+ compress
21
+ sharedscripts
22
+ postrotate
23
+ /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
24
+ endscript
25
+ }
You can’t perform that action at this time.
0 commit comments