We will take into account one of the API rules: always use a secure connection. Assuming that you are using Nginx, this can be done in four easy steps:
Create a directory,
/etc/nginx/ssl
:$ sudo mkdir /etc/nginx/ssl
Generate a new certificate using the following command:
$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
At this point you will be asked to provide some information about the new certificate, as shown in the following diagram:
Open the
learning-phalcon.localhost
configuration file (/etc/nginx/sites-available/learning-phalcon.localhost
) and enable SSL:server { listen 80; listen 443 ssl; ssl_certificate /etc/nginx/ssl/nginx.crt; ssl_certificate_key /etc/nginx/ssl/nginx.key; #....rest of the code }
Then reload the Nginx configuration:
$ sudo service nginx reload
Now you can try to access https://learning-phalcon.localhost/
. In any browser that you are using, you will...