Skip to content

Instantly share code, notes, and snippets.

@4lun
Last active April 18, 2024 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4lun/913d0288b0fdc4a31810b436d1c62017 to your computer and use it in GitHub Desktop.
Save 4lun/913d0288b0fdc4a31810b436d1c62017 to your computer and use it in GitHub Desktop.
Get access logs on DigitalOcean App Platform (with PHP via heroku-php-apache2) logging the forwarded Client IP by default on the "Runtime Logs" tab
# Update run_command in app spec to pass config, e.g. `run_command: heroku-php-apache2 -C apache_app.conf public/`
DirectoryIndex index.php index.html index.htm
# mod_remoteip should be loaded by default, but needs configuration
RemoteIPHeader DO-Connecting-IP
# Trust any private IPv4 ranges
RemoteIPTrustedProxy 10.0.0.0/8
RemoteIPTrustedProxy 172.16.0.0/12
# We need to update the LogFormat, substituting %h with %a (have also added %V to include Host/CanonicalName)
# - Default value: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" heroku
# - From https://github.com/heroku/heroku-buildpack-php/blob/1adf23f08e17bdd8cf034c04bebfef1c55474810/conf/apache2/heroku.conf#L23
LogFormat "%a %l %u %t %V \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" heroku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment