I'm trying to run Apache behind an Nginx reverse proxy. However, Apache aborts the connection if both X-Forwarded-For and X-Forwarded-Host headers are present in the request. Passing only one of these headers works fine. Using httpie:

$ http http://my-host:9000
HTTP/1.1 200 OK

$http http://my-host:9000 'X-Forwarded-For:'
HTTP/1.1 200 OK

$ http http://my-host:9000 'X-Forwarded-Host:my-host:443'
HTTP/1.1 200 OK

$ http http://my-host:9000 'X-Forwarded-For:' 'X-Forwarded-Host:my-host:443'
http: error: ConnectionError: ('Connection aborted.', BadStatusLine("''",))

These requests where run on the same machine that is running Apache. Running the problematic request from a separate machine works:

some-other-machine $ http http://my-host:9000 'X-Forwarded-For:' 'X-Forwarded-Host:my-host:443'
HTTP/1.1 200 OK

The machine running Apache is a Vagrant virtual machine with Debian 8.6 and a fixed IP in a private network. Apache version is 2.4.10 running on the default configuration.

I've tried to disable as many Apache modules as I could, here are the ones that are still enabled:

$ apachectl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 rewrite_module (shared)
 rpaf_module (shared)
 setenvif_module (shared)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.