Skip to content

Commit 6e16c8d

Browse files
committed
remove proxy dependency on log rotation
1 parent 3f2b8cb commit 6e16c8d

File tree

16 files changed

+120
-28
lines changed

16 files changed

+120
-28
lines changed

CHANGES.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,45 @@
1515
[Unreleased](https://github.com/bird-house/birdhouse-deploy/tree/master) (latest)
1616
------------------------------------------------------------------------------------------------------------------
1717

18-
[//]: # (list changes here, using '-' for each new entry, remove this when items are added)
18+
## Changes
19+
20+
- Remove `proxy` component's dependency on `scheduler` and `scheduler-job-logrotate-nginx`
21+
22+
Creates new settings in `optional-components/proxy-log-volume` that create the `proxy-logs` docker volume as well
23+
as instructing Nginx to write access logs to an additional log file (specified by `PROXY_LOG_PATH`). These settings
24+
are included as a `COMPONENT_DEPENDENCY` in components that require access to the the `proxy` access logs as a
25+
regular file. If no components require access to these logs as a regular file then the `proxy` component will only
26+
write access logs to the stdout stream for that container.
27+
28+
Right now, the only components that require access to logs in this way are `components/canarie-api` and
29+
`optional-components/prometheus-log-parser`. Both of these now include `optional-components/proxy-log-volume` as a
30+
`COMPONENT_DEPENDENCY`.
31+
32+
Note: this means that if no optional components require `optional-components/proxy-log-volume` as a dependency
33+
then logs from the `proxy` container will only be written to stdout/stderr. This means that there is no need
34+
for any additional custom log rotation handling since the logs are handled directly by docker. This means that
35+
the `proxy` service itself no longer need to be dependant on the `scheduler` and `scheduler-job-logrotate-nginx`
36+
components.
37+
38+
Note: a previous discussion suggested that logs could be parsed directly from the stdout stream of the `proxy`
39+
container. However, there is no way to do so that doesn't require very hacky workarounds. Possible solutions that
40+
were explored and rejected include:
41+
42+
- Mounting the log file from the `proxy` container from the host to the relevant containers.
43+
Rejected because this practice is highly discouraged by docker as the actual storage location of log files
44+
is not standardized and may be changed in future versions.
45+
- Writing logs to a named pipe or socket within the `proxy` container.
46+
Rejected because this is very difficult to set up and is untested when then mounted to other containers.
47+
Also, a different named pipe would be required for each consumer which is currently very difficult to set up
48+
using birdhouse's deployment tools.
49+
50+
**Breaking Change**: if a custom component (not included in this repository) uses the `proxy-logs` named volume.
51+
It must now include `optional-components/proxy-log-volume` as a `COMPONENT_DEPENDENCY` for that custom component.
52+
53+
**Breaking Change**: if `SCHEDULER_JOB_BACKUP_ARGS` specifies `-l proxy` explicitly (not `-l '*'`) then this should
54+
be changed to `-l proxy-log-volume` since the backup script has been moved. Note that it is not necessary to
55+
specify `-l proxy-log-volume` if `--birdhouse-logs` is also specified because the log data is identical in both.
56+
1957

2058
[2.20.2](https://github.com/bird-house/birdhouse-deploy/tree/2.20.2) (2026-01-05)
2159
------------------------------------------------------------------------------------------------------------------

birdhouse/components/canarie-api/config/proxy/docker-compose-extra.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ services:
22
proxy:
33
volumes:
44
- ./components/canarie-api/config/proxy/conf.extra-service.d:/etc/nginx/conf.extra-service.d/canarie-api:ro
5-
- proxy-logs:${PROXY_LOG_DIR}

birdhouse/components/canarie-api/default.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export DELAYED_EVAL="
1313
# add any component that this component requires to run
1414
COMPONENT_DEPENDENCIES="
1515
./components/proxy
16+
./optional-components/proxy-log-volume
1617
"

birdhouse/components/canarie-api/docker-compose-extra.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ services:
4646
entrypoint: /entrypoint
4747
logging: *default-logging
4848

49+
# Note: proxy-logs volume is defined in the proxy-logs-volume component
4950
volumes:
5051
canarie-data:
51-
proxy-logs:

birdhouse/components/proxy/default.env

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ export PROXY_INCLUDE_FOR_PORT_80='$([ x"$BIRDHOUSE_ALLOW_UNSECURE_HTTP" = x"True
3535
export PROXY_LISTEN_443_PARAMS=""
3636
export PROXY_LISTEN_80_PARAMS=""
3737

38-
export PROXY_LOG_DIR="/var/log/nginx/"
39-
export PROXY_LOG_FILE="access_file.log"
40-
export PROXY_LOG_PATH='${PROXY_LOG_DIR}/${PROXY_LOG_FILE}'
4138

4239
export DELAYED_EVAL="
4340
$DELAYED_EVAL
44-
PROXY_LOG_PATH
4541
BIRDHOUSE_PROXY_SCHEME
4642
BIRDHOUSE_ALLOW_UNSECURE_HTTP
4743
PROXY_INCLUDE_HTTPS
@@ -65,15 +61,7 @@ export OPTIONAL_VARS="
6561
\$PROXY_INCLUDE_FOR_PORT_80
6662
\$PROXY_READ_TIMEOUT_VALUE
6763
\$BIRDHOUSE_PROXY_ROOT_LOCATION
68-
\$PROXY_LOG_FILE
69-
\$PROXY_LOG_PATH
7064
\$PROXY_INCLUDE_HTTPS
7165
\$PROXY_LISTEN_443_PARAMS
7266
\$PROXY_LISTEN_80_PARAMS
7367
"
74-
75-
# TODO: remove this dependency once https://github.com/bird-house/birdhouse-deploy/issues/618 is resolved
76-
COMPONENT_DEPENDENCIES="
77-
./components/scheduler
78-
./optional-components/scheduler-job-logrotate-nginx
79-
"

birdhouse/components/proxy/nginx.conf.template

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ http {
1616
default_type application/octet-stream;
1717

1818
# NOTE: if this log_format ever changes, make sure to update the relevant code in the
19-
# prometheus-log-parser component as well to match the change.
19+
# components that assume this log format.
2020
log_format main '$remote_addr - $remote_user [$time_iso8601] "$request" '
2121
'$status $body_bytes_sent "$http_referer" '
2222
'"$http_user_agent" "$http_x_forwarded_for"';
2323

24-
access_log ${PROXY_LOG_PATH} main;
25-
2624
sendfile on;
2725
#tcp_nopush on;
2826

birdhouse/optional-components/README.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,3 +692,41 @@ Note that you do *not* need an SSL certificate set up to deploy the stack in thi
692692
.. warning::
693693

694694
**DO NOT** enable this component in production. This is intended for local development and test purposes only!
695+
696+
Proxy Log Volume
697+
----------------
698+
699+
This optional setting creates a named docker volume `proxy-logs` that contains the logs directory for the `proxy` component.
700+
701+
It also creates an Nginx configuration that instructs the proxy service to write access logs to a regular file in that directory.
702+
703+
.. note::
704+
705+
By default, access logs are only written to the stdout stream of the `proxy` docker container.
706+
707+
.. note::
708+
709+
Because access logs are now being written to a regular file, enabling this component will also enable the
710+
`optional-components/scheduler-job-logrotate-nginx` scheduler job to ensure that this file is rotated and that it will not
711+
get too big.
712+
713+
.. warning::
714+
715+
**DO NOT** enable this setting directly. It will be enabled as a component dependency by other components that require access
716+
to the `proxy` access logs as a regular file.
717+
718+
719+
If you are creating a custom component that requires access to the `proxy` access logs, add the following to that component's
720+
`default.env` file:
721+
722+
.. code::shell
723+
724+
COMPONENT_DEPENDENCIES="
725+
./optional-components/proxy-log-volume
726+
"
727+
728+
This will ensure that the proxy log volume setting will be enabled. You can then mount the volume named `proxy-logs` to any container
729+
that your custom component creates and read the `proxy` access logs at a file defined by the configuration variable `PROXY_LOG_FILE`.
730+
731+
For example, if `PROXY_LOG_FILE` is set to ``access_file.log`` (the default) and you mount the `proxy-logs` volume to the ``/logs``
732+
directory in your container, the `proxy` access logs can be read at ``/logs/access_file.log`` in your container.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
services:
22
proxy:
33
volumes:
4+
# Note: proxy-logs volume is defined in the proxy-logs-volume component
45
- proxy-logs:${PROXY_LOG_DIR}
56
prometheus-log-parser:
67
volumes:
78
- proxy-logs:/var/log/proxy
89
environment:
910
- PROXY_LOG_FILE=${PROXY_LOG_FILE}
10-
11-
volumes:
12-
proxy-logs:

birdhouse/optional-components/prometheus-log-parser/default.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ export DELAYED_EVAL="
1616
$DELAYED_EVAL
1717
PROMETHEUS_LOG_PARSER_IMAGE
1818
"
19+
20+
COMPONENT_DEPENDENCIES="
21+
./components/proxy
22+
./optional-components/proxy-log-volume
23+
"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config/proxy/conf.extra-directives.d/proxy-log.conf

0 commit comments

Comments
 (0)