Fix php logging to STDERR so Docker logs work
This commit is contained in:
parent
e469e14ae1
commit
923fdee657
|
|
@ -57,5 +57,9 @@ RUN chmod +x /var/www/cmc-sales/run_vault.sh
|
|||
RUN chmod +x /var/www/cmc-sales/run_update_invoices.sh
|
||||
|
||||
|
||||
# Ensure Apache error/access logs go to Docker stdout/stderr
|
||||
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
|
||||
ln -sf /dev/stderr /var/log/apache2/error.log
|
||||
|
||||
# By default, simply start apache.
|
||||
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ class AppController extends Controller {
|
|||
$tailscaleName = isset($_SERVER['HTTP_TAILSCALE_USER_NAME']) ? $_SERVER['HTTP_TAILSCALE_USER_NAME'] : null;
|
||||
|
||||
if ($tailscaleLogin) {
|
||||
// Log Tailscale authentication attempt
|
||||
error_log('[TAILSCALE_AUTH] Attempting authentication for: ' . $tailscaleLogin);
|
||||
|
||||
// Try to find user by email address from Tailscale header
|
||||
$user = $this->User->find('first', array(
|
||||
'recursive' => 0,
|
||||
|
|
@ -57,6 +60,9 @@ class AppController extends Controller {
|
|||
'recursive' => 0,
|
||||
'conditions' => array('User.id' => $this->User->id)
|
||||
));
|
||||
error_log('[TAILSCALE_AUTH] Created new user: ' . $tailscaleLogin);
|
||||
} else {
|
||||
error_log('[TAILSCALE_AUTH] Failed to create user: ' . $tailscaleLogin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -64,12 +70,19 @@ class AppController extends Controller {
|
|||
|
||||
// Fall back to HTTP basic auth if no Tailscale auth or user not found
|
||||
if (!$user && isset($_SERVER["PHP_AUTH_USER"])) {
|
||||
error_log('[BASIC_AUTH] Attempting authentication for: ' . $_SERVER["PHP_AUTH_USER"]);
|
||||
$user = $this->User->find('first', array(
|
||||
'recursive' => 0,
|
||||
'conditions' => array('User.username' => $_SERVER["PHP_AUTH_USER"])
|
||||
));
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
error_log('[AUTH_SUCCESS] User authenticated: ' . $user['User']['email']);
|
||||
} else {
|
||||
error_log('[AUTH_FAILED] No valid authentication found');
|
||||
}
|
||||
|
||||
$this->set("currentuser", $user);
|
||||
|
||||
if($this->RequestHandler->isAjax()) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,12 @@
|
|||
NameVirtualHost *:80
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /var/www/cmc-sales/app/webroot
|
||||
|
||||
# Send Apache logs to stdout/stderr for Docker
|
||||
ErrorLog /dev/stderr
|
||||
CustomLog /dev/stdout combined
|
||||
|
||||
# Ensure PHP errors are also logged
|
||||
php_flag log_errors on
|
||||
php_value error_log /dev/stderr
|
||||
</VirtualHost>
|
||||
|
|
|
|||
|
|
@ -633,7 +633,8 @@ html_errors = Off
|
|||
; empty.
|
||||
; http://php.net/error-log
|
||||
; Example:
|
||||
error_log = /var/log/php_errors.log
|
||||
; For Docker: Send errors to stderr so they appear in docker logs
|
||||
error_log = /dev/stderr
|
||||
; Log errors to syslog (Event Log on NT, not valid in Windows 95).
|
||||
;error_log = syslog
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue