Redirect http:80 to https:443 Using only NodeBalancer
I'd like to redirect all http traffic from users to https.
I don't want to hit my linode vm, but rather do it all on the NB.
I couldn't find anything on the NB configuration that does that.
I searched around but most answers use web servers or firewalls.
How can I do this straight on the NB?
http://web2nodebalancer -> https://web2nodebalancer
Best Regards
2 Replies
You can't. The NodeBalancer is a very simple, very dumb, load balancer. All it does is pass traffic to your backends. If the web server on your backends is nginx, a simple http to https redirect won't really use any resources anyway. Here's an example nginx config snippet to redirect all HTTP requests to HTTPS, regardless of what domain:
server {
listen [::]:80 default_server ipv6only=off deferred reuseport;
server_name _;
access_log off;
return 301 https://$host$request_uri;
}
If you only want to redirect some domains, remove default_server
and change the server_name
directive to use those domains.
Awesome! I just wanted a confirmation of that fact as I found nothing on the topic. We're using nodejs so redirecting isn't a big deal.
Much appreciated friend :o)