Protecting the Phoenix app with SSL
In a production scenario, it will be likely for a Phoenix application to listen to requests using a secure protocol. HTTPS will be used in detriment of plain HTTP.
To accept connections securely, we need to launch the application with SSL support.
Fortunately, in Phoenix, configuring SSL is quite simple.
In a Phoenix application, place the *.key
and *.cert
files under the priv
directory.
To configure SSL in a Phoenix application, we will need to add the following to the config/prod.exs
file:
We insert the configuration for HTTPS connections by defining the values of the port where the application will listen (443 is the default HTTPS port), the name of the host (the host for which the certificate files were generated), and...