aws beanstalk nodejs redirect http to https
Create a file named
force-https.config
in the top-level.ebextensions
directory of your Node.js application.Inside
force-https.config
, add the following configuration to redirect all HTTP requests to HTTPS:
files:
/etc/httpd/conf.d/force-https.conf:
mode: "000644"
owner: root
group: root
content: |
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</VirtualHost>
Deploy your application to AWS Elastic Beanstalk to apply the configuration changes.
After deployment, all incoming HTTP requests will be automatically redirected to HTTPS.