I have nginx server that sends 404 errors to apache httpd at 1.1.1.1:8081. How can I pass all original headers to the error server?
I have the following config:
server {
error_page 404 = http://1.1.1.1:8081/404.php?remote=1;
}
When examining headers in 404.php I get client original ip but no cookies from the client; also, I get request uri set to 404.php?remote=1
and not url that caused the 404 error:
<?php
// 404.php file
file_put_content("log.txt", $_SERVER['REQUEST_URI'], FILE_APPEND); // :(
file_put_content("log.txt", $_SERVER['REMOTE_ADDR'], FILE_APPEND); // Ok
file_put_content("log.txt", $_COOKIE['MyCookie'], FILE_APPEND); // :( empty
?>
It isn't pretty, but one possible solution is to use a named location with a proxy pass to your error handler and then add as many custom headers as you need with the desired information. It means customising the 404.php file also.
For example: