No matter what the visitor types www.example.net or http://www.example.net or http://example.net i want all of the requests to be redirected to https://example.net currently i have managed to redirected requests that are coming from www.example.net and https://www.example.net to https://example.net but i can't find a solution for http://example.net to https://example.net

Current config of nginx default is this:

server {
server_name www.example.net;
return 301 example.net$request_uri;
}
server { 
listen 80;
listen [::]:80;
server_name example.net;
location / {
  proxy_set_header   X-Forwarded-For $remote_addr;
  proxy_set_header   Host $http_host;
  proxy_pass localhost:3000;
  proxy_http_version 1.1;
  proxy_set_header   Upgrade $http_upgrade;
  proxy_set_header   Connection "upgrade";
}
}

Application is in NodeJs, server is from AWS while for web-server i use nginx

Incorporate this into your server block:

server {
    server_name www.sld.tld;
    return 301 $scheme://sld.tld$request_uri;
}

I hope that helps :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.