1
votes

I've searched high and low and I feel this is the final hurdle for my project. I'm trying to redirect all http traffic to https.

Currently when typing domain.info, it redirects to https://domain.info:80 and returns ERR_SSL_PROTOCOL_ERROR

But replacing the 80 with 443 gives me my webpage just fine.

My server is behind a load balancer too, I have my certificates in the LB and none in my server. I'm using NGINX as my webserver. Basically this is my setup:

user>https>load balancer>http>server

Thanks so much in advance!!

2

2 Answers

0
votes
  1. Firstly, catch all HTTP incoming:
server {
   listen 80 default_server;
   server_name _;
   return ....;
}
  1. then redirect to HTTPS permanently
server {
   listen 80 default_server;
   server_name _;
   return 301 https://$host$request_uri;
}

or...

server {
    listen 443 ssl default_server;
    server_name foo.com;
}

server {
    listen 443 ssl default_server;
    server_name foo.com;
}
0
votes

Directly in the load balancer, you can add a redirection rule, did you try to play with that?

In the load balancer listener, update the default rule for HTTP:80 and configure it like this :

HTTP 80: default action
IF
Requests otherwise not routed
THEN
Redirect to https://#{host}:443/#{path}?#{query}
Status code:HTTP_301