I have provisioned a scalable EB(Elasticbeanstalk) rails(puma) instance. I have applied for https through ACM(Amazon Certificate Manager) and applied it to my load balancer. HTTPS is enabled for my website now. But how do I force redirect to https? I have tried a number of solutions online where it was suggested to make a nginx configuration setting manually through .ebextensions and I am not sure where to get the certificate from ACM for this?(I am assuming that is not possible with ACM right now?). How do I force HTTPS?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- How to generate 12 digit unique number in redshift
- Use awslogs with kubernetes 'natively'
- Eager-loading association count with Arel (Rails 3
The current AWS EB Rails and Node.js setups both use nginx (if your web server is apache see this answer), so the following should work (adapted from this question):
Create the file
.ebextensions/01-force-https.config
(the.config
is important, not.conf
) with the following content.If your environment is a single instance:
If your environment is load balanced, you unfortunately cannot simply add to the existing config but need to modify it with sed:
Then add it to your git repo or app bundle and
eb deploy
. This creates/etc/nginx/conf.d/01-force-https.conf
which is automatically included from/etc/nginx/nginx.conf
. Note thateb deploy
won't delete the file on the server if you later remove the corresponding file from.ebextensions
. Also, I found the following helpful in debugging througheb ssh
: