Restore HTTP access logging on the minimal image's :443 vhost - #155
Merged
Conversation
An Apache CustomLog inside a vhost REPLACES the one inherited from the server config. default-ssl.conf declared only ssl_request_log, so conf-enabled/other-vhosts-access-log.conf never applied to :443 -- and since the ALB speaks only to :443, the :80 vhost's access.log stayed empty too. The result was no HTTP access logging anywhere for a dedicated-hosting customer. ssl_request_log was the only record of a request, and it is a poor one: its %h is the load balancer's private address rather than the caller, and its format carries no status code, referer, or user agent. Nothing shipped it off the container either -- it is a real file on the ephemeral /var/log volume, so it died with the task. Found while verifying demo's migration: a probe request could not be located in CloudWatch at all. The log-tailer sidecar appears to cover this (it tails /var/log/apache2/access.log) but cannot -- that path is a symlink to /dev/stdout in the php:apache base image, and /dev/stdout is a write end, so the tail reads nothing. The sidecar entry looked like coverage while providing none. Adds a combined-format CustomLog to access.log, which reaches the container's stdout and therefore the awslogs driver. Client identity comes from X-Forwarded-For, since %h is the load balancer. The whole header is logged deliberately: the ALB appends the true peer as the last element, so only the last one is trustworthy, and keeping the chain visible beats hiding a forged prefix behind a single value. ssl_request_log is kept for the TLS protocol/cipher detail the combined format does not carry. Verified on a built image: `apache2ctl -t` reports Syntax OK, and requests through the vhost emit, on stdout, 203.0.113.9 ... "GET /?abuse-probe HTTP/1.1" 200 4031 "-" "curl/8.7.1" 198.51.100.4 ... "GET /nonexistent-page HTTP/1.1" 404 298 "-" "curl/8.7.1" including the 404 the previous configuration could not record.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
An Apache
CustomLoginside a vhost replaces the one inherited from the server config.default-ssl.confdeclared onlyssl_request_log, soconf-enabled/other-vhosts-access-log.confnever applied to:443— and since the ALB speaks only to:443, the:80vhost'saccess.logstayed empty too.Net effect: no HTTP access logging anywhere for a dedicated-hosting customer.
ssl_request_logwas the only record of a request, and it's a poor one:10.120.0.74is the load balancer, not the caller. No status code, no referer, no user agent. And nothing ships it off the container — it's a real file on the ephemeral/var/logvolume, so it dies with the task.How it hid
Found while verifying
demo's migration: a probe request couldn't be located in CloudWatch at all.The
log-tailersidecar insimplerisk-customers-cdkappears to cover this — it tails/var/log/apache2/access.log. It can't. That path is a symlink to/dev/stdoutin thephp:apachebase image, and/dev/stdoutis a write end, so the tail reads nothing forever. The sidecar entry looked like coverage while providing none.The fix
A combined-format
CustomLogtoaccess.log, which reaches the container's stdout and therefore theawslogsdriver — the Docker-native path, needing no sidecar entry.Client identity comes from
X-Forwarded-Forsince%his the load balancer. The whole header is logged deliberately: the ALB appends the true peer as the last element, so only the last one is trustworthy, and keeping the chain visible beats hiding a forged prefix behind a single value. (mod_remoteipwould be the alternative, but it needs a trusted-proxy range that varies per region, and misconfiguring it makes spoofing win silently.)ssl_request_logis kept for the TLS protocol/cipher detail the combined format doesn't carry.Verification
Built the image and ran
apache2ctl -t→Syntax OK. Requests through the vhost emit on stdout:Including the 404 the previous configuration could not record at all.