You need to setup your app to run over https for localhost
You can follow steps given in this to setup HTTPS on ubuntu
https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-12-04
You need to do following steps:
install apache (if you do not have)
sudo apt-get install apache2
Step One—Activate the SSL Module
sudo a2enmod ssl
sudo service apache2 restart
Step Two—Create a New Directory
sudo mkdir /etc/apache2/ssl
Step Three—Create a Self Signed SSL Certificate
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache/ssl/apache.key -out /etc/apache2/ssl/apache.crt
With this command, we will be both creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.
The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your site's IP address.
Common Name (e.g. server FQDN or YOUR name) []:example.com or
localhost
Step Four—Set Up the Certificate
sudo vim /etc/apache2/sites-available/default-ssl
Find following lines and edit those with your settings
ServerName localhost or example.com
SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Step Five—Activate the New Virtual Host
sudo a2ensite default-ssl
sudo service apache2 reload