Http to Https AWS Elasticbeanstalk

I am using AWS Elasticbeanstalk for my Spring MVC web application. I want to redirect the whole request to https. I tried to follow this. How to get https to elastic beanstalk? but it did not work for me. This code redirects to https, but my application does not work. It shows: "This page does not work." Code for reference

<VirtualHost *:80>
  RewriteEngine on
  RewriteCond %{HTTP:X-Forwarded-Proto} =http
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  <Proxy *>
    Order Allow,Deny
    Allow from all
  </Proxy>
  ProxyPass / http://localhost:8080/ retry=0
  ProxyPassReverse / http://localhost:8080/
  ProxyPreserveHost on

  ErrorLog /var/log/httpd/elasticbeanstalk-error_log
</VirtualHost>
+4
source share
1 answer

Suppose you already tested HTTPS, working fine when your site has already visited HTTPS. If you cannot add this .ebextensions/loadbalancer-terminatehttps.configcontent file as shown below:

option_settings:
  aws:elb:listener:443:
    ListenerProtocol: HTTPS
    SSLCertificateId: arn:aws:acm:us-west-2:<your-account-id>:certificate/<certificate-arn-on-aws-acm>
    InstancePort: 80
    InstanceProtocol: HTTP

, , - Apache , , HTTP HTTPS, .ebextensions/001_ssl_rewrite.config

Apache 2.4 +

files:
    "/etc/httpd/conf.d/ssl_rewrite.conf":
        mode: "000644"
        owner: root
        group: root
        content: |
            RewriteEngine On
            <If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
            RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
            </If>

Apache 2.2.X

files:
    "/etc/httpd/conf.d/ssl_rewrite.conf":
        mode: "000644"
        owner: root
        group: root
        content: |
            LoadModule rewrite_module modules/mod_rewrite.so
            RewriteEngine On
            # This will enable the Rewrite capabilities
            RewriteCond %{HTTPS} !=on
            # This checks to make sure the connection is not already HTTPS
            RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

, Apache beanstalk

: fooobar.com/questions/124626/... fooobar.com/questions/124626/... p >

0

Source: https://habr.com/ru/post/1695414/


All Articles