INDIA +91 882 616 7094 | USA +1 949 299 0280 | GERMANY +49 176 3465 1507 info@navyuginfo.com

If we use any of the Google Map functions such as getCurrentLocation on the navigator, it throws an error if it is not accessed over a secure origin.

PS: localhost is treated as a secure origin over HTTP, so if you’re able to run your server from localhost, you should be able to test the feature on that server.

As we can’t have an HTTPS Certificate for a test server, we can configure it to be over HTTPS by using Self Signed Certificates.

Here is the link to generate self-signed certificates on an Ubuntu machine

https://help.ubuntu.com/12.04/serverguide/certificates-and-security.html

Then, you will have to configure Nginx over SSL and here is a code snippet for that:

server {

            listen 443 ssl;
            server_name <your-server-dns>;
            underscores_in_headers on;
            ssl_certificate <path-to-generated-cert>;
            ssl_certificate_key  <path-to-generated-private-key>;

}

If you want to redirect an HTTP request to HTTPS on Nginx, you can do it this way:

server {
listen 80;
server_name project.navyuginfo.com;
return 301 https://$server_name$request_uri;
}

Above method will let you enable google map functions over a secure network.