0

I have try to config nginx: /etc/nginx/nginx.conf

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name 10.0.0.10; #This is my private IP
    return 301 https://$server_name$request_uri;
    # OR return 301 https://$host$request_uri
}

But it cannot redirect from HTTP to HTTPS. Please help me on this. Thanks.

Brian
  • 3
  • 2

1 Answers1

0

I think the issue is the IP as server name. Try and edit your hosts file and add an entry for the IP. For example:

10.0.0.10 myserver.test

The edit the nginx configuration and change the server_name parameter to:

server_name myserver.test;

restart nginx or reload the configuration.

Fabrizio Mazzoni
  • 671
  • 1
  • 9
  • 24
  • HTTPS needs to use SSL with HTTP protocol to build a secure and verified connection. It is heavily relies on the domain name. In case you are specifing the IP, it won't work as expected. You can use ` server_name _;` as your server name, but your client must have a valid DNS configuration, at least hosts file needs to know to which IP redirect your request. – Dmitriy Kupch Dec 05 '18 at 16:44