https-redirect-php don't works correctly on Amazon Linux 2 Instances
Closed this issue · 2 comments
The current solution just doesn't works as expected.
The folder /etc/httpd/conf.d
is overwritten after any deploy and the file `http-redirect.conf' will be removed.
I discovered this solution for this issue:
files:
"/tmp/http-redirect.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_USER_AGENT} !ELB-HealthChecker
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
container_commands:
moveredirect:
command: "sudo mv /tmp/http-redirect.conf /var/proxy/staging/httpd/conf.d/http-redirect.conf"
Looks like all the configuration files are created on the /var/proxy/staging/httpd
folder and then copied to /etc/httpd/
automatically.
I don't know if it is the best solution but this works for me now.
First I thought ebextensions aren't working on Amazon Linux 2 at all, then I stumbled upon this post and found out the config files just get overwritten. The solution I eventually encountered doesn't require the workaround above — the https/conf.d files just need to be set differently in the repository.
On Amazon Linux 1 my files were in:
|.ebextensions
|---cors.config
Now they need to be placed to:
|.platform
|---httpd (if you're using Apache proxy)
|------conf.d
|---------cors.conf
The conf file itself needs to contain only the actual configuration that you had in the "content" attribute, without "files", "mode", "owner", and the rest.
Thanks