Hastps Overvoltage Hastps Override

I know this question has been asked before, but nothing works for me. I tried several different things, such as the answers described in these questions:

How to get a proxy server that supports nginx proxy server to automatically redirect from HTTP to HTTPS? Redirecting EC2 elb from http to https

None of them seem to work. I am aws noob, so I'm not quite sure how editing configuration files works, or if I did something wrong.

My setup is this:

My current nginx.config file in my .ebextensions folder (got this from in this article ):

files: "/tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf" : mode: "000755" owner: root group: root content: | upstream nodejs { server 127.0.0.1:8081; keepalive 256; } server { listen 8080; set $fixedWWW ''; set $needRedir 0; # nginx does not allow nested if statements # check and decide on adding www prefix if ($host !~* ^www(.*)) { set $fixedWWW 'www.'; set $needRedir 1; } # what about that https? the traffic is all http right now # but elastic load balancer tells us about the original scheme # using $http_x_forwarded_proto variable if ($http_x_forwarded_proto != 'https') { set $needRedir 1; } # ok, so whats the verdict, do we need to redirect? if ($needRedir = 1) { rewrite ^(.*) https://$fixedWWW$host$1 redirect; } location / { proxy_pass http://nodejs; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } gzip on; } 

But it does nothing. I'm out of ideas. I’m not sure that I am missing a step or something else, but I don’t know what to do. As a workaround, I have my own external side of angularjs that redirect requests without HTTPS, but this is too hacky, and some of the DOMs appear before the redirect, I would like to redirect to the load balancer - where it should be redirected.

+7
amazon-web-services amazon-elb elastic-beanstalk nginx
source share
1 answer

It looks like you are trying to do both redirection for non-WWW, and for connections other than HTTPS. Have you tried the simpler case of just http: // -> https: //?

 if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; } 

It is sometimes easier to handle this through two redirects: one from HTTP to HTTPS and one from non-WWW to WWW. In fact, if you are going to register your site through HSTS (https-everywhere), they require this approach.

Edit: Also, having just noticed the first line of your config, you can try to directly insert the nginx file:

 files: "/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf" : 
+2
source

All Articles