This forum provides solutions for aws developers for their issues.It provides solutions for aws elastic ip, ec2 instance, public ip,route53 pricing, load balancers in aws,Orchestration, ebs,, lambda, installing mongodb on ubuntu etc.

Saturday, 27 May 2017

Http to Https redirection for ec2 instance

If you want traffic coming to web server redirect to https without change the backed listener to port 443,
ELB supports a HTTP header called X-FORWARDED-PROTO. you can force the http to https redirection by writing simple rule.
If your using IIS,
<rewrite xdt:Transform="Insert">
    <rule name="HTTPS rewrite behind ELB rule" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
        <add input="{HTTP_X_FORWARDED_PROTO}" pattern="^http$" ignoreCase="false" />
      <action type="Redirect" redirectType="Found" url="https://{SERVER_NAME}{URL}" />
If your using Apache,

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [NE]

If your using NGINX,
server {
    listen 80;
    location / {
        if ($http_x_forwarded_proto != 'https') {
            return 301 https://$server_name$request_uri;
        try_files $uri $uri/ /index.php?$args;

0 coment�rios:

Post a comment


Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts