Had issues with Safari not loading WordPress sites running on AWS Elastic Beanstalk. Looked for solutions, everything pointed to setting H2Upgrade off in an httpd config file. I tried seven different combinations before I came up with this fix –
- Use .platform/hooks/postdeploy to run a script that builds a config file in /etc/httpd/conf.d during deployment
- Use another file in the same folder, named to run later, to restart https
File 1 – .platform/hooks/postdeploy/02_httpd_config.sh
#!/usr/bin/env bash
echo “02_httpd_conf.sh running”
target=/etc/httpd/conf.d/safari.conf
target_d=/etc/httpd/conf.d
if [ ! -d $target_d ]; then
echo “$target_d does not exist”
else
echo “$target_d exists”
fi
if [ ! -f $target ]; then
echo “$target does not exist”
sudo sh -c “cat > $target” <<EOT
H2Upgrade off
Header unset Upgrade
EOT
sudo chown $target
sudo chmod -x $target
sudo ls -al $target_d
else
echo “$target exists”
fi
echo “02_httpd_conf.sh complete”
REMEMBER –
1. Format, indentation is very important in these files.
2. chmod +x .platform/hooks/postdeploy/02_httpd_config.sh or it will not run
File 2 – .platform/hooks/postdeploy/99-httpd_restart.sh
#!/usr/bin/env bash
sudo systemctl restart httpd
REMEMBER –
1. chmod +x .platform/hooks/postdeploy/02_httpd_config.sh or it will not run
2. If you copy this files, beware of “smart quotes”
Beyond looking at the site with Safari, if you use curl -v https://yournamehere.com, you will see
http2 error: Invalid HTTP header field was received: frame type: 1, stream: 1, name: [upgrade], value: [h2,h2c]
After the fix, curl returns html.
In the first file, the unset directive worked, H2Upgrade off did not. I left it in to remind me of what a pain it was to track this down and fix.