I also tried to fix this in an apache reverse proxy but ended up running the setup command directly without going through apache. After that I no longer saw the HEAD request from heartbeat that returned a 404, followed by the PUT (with strange encoding on the slashes) that returned 405.
After the setup was done elsewhere the heartbeat agent no longer made these requests and logs in the apache reported 200s when the agent POSTed to _bulk
The first request(s):
"GET _alias/heartbeat-7.11.1 HTTP/1.1" 404
"HEAD heartbeat-7.11.1 HTTP/1.1" 404
"PUT %3Cheartbeat-7.11.1-%7Bnow%2Fd%7D-000001%3E HTTP/1.1" 405
After running heartbeat setup elsewhere:
"GET _alias/heartbeat-7.11.1 HTTP/1.1" 200
"POST _bulk HTTP/1.1" 200
To run the setup I used the following command from a location where I could reach ES without going through the Apache server:
docker run docker.elastic.co/beats/heartbeat:7.11.1 setup -E output.elasticsearch.hosts=["elasticsearchhostname:9200"]
Related: Failed to create alias: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">