Redirect traffic from http to https on Nginx

You have to configure the redirection from http to https at the domain level, in your domain file in the sites-avaliable folder.

You can find the sites-available configuration in: /etc/nginx/sites-available

There you will generally find a configuration file for each domain that usually has the same name as the domain to serve, something like “example.com”.

Within that file you will have to edit or create a “server” section, in which port 80 traffic is listened to and redirected to the domain name but with https.

For example, this is how we have it at .com:

server { listen 80 default_server; listen :80 default_server; return 301 $request_uri; }

The redirect is generally a 301 type, which indicates that it is a permanent redirect.

We direct the traffic to our main domain, but with https://.

In order to keep the rest of the URL after the domain, for example to redirect http:///manuales to /manuales, “$request_uri” is placed after the domain name.

See also  What are XPS documents
Loading Facebook Comments ...
Loading Disqus Comments ...