HTTPS Configuration¶
Enabling HTTPS in Router¶
The application uses Nginx as a router for handling HTTPS requests. HTTPS is required for secure communication. To enable HTTPS, you need to configure the Nginx settings with SSL certificates.
Prerequisites¶
- DNS A Records: Properly configured DNS A records pointing to your server's IP address (if using a domain name).
- SSL Certificates: SSL certificates are automatically configured during the
set_hostnamescript execution. The certificates are stored in therouterdirectory and can be either: - Your own valid SSL certificate (
.crtfile) and key (.keyfile). - A self-signed certificate automatically generated by the
set_hostnamescript.
Nginx Configuration Directory¶
The Nginx configuration files are located in the router directory under the application's installation path. This directory is mounted into the Nginx container using the Docker Compose configuration.
Example Nginx Configuration for HTTPS¶
Below is an example of the relevant part of the Nginx configuration file. The set_hostname script automatically configures these settings, but you can verify or manually adjust them if needed:
### UNCOMMENT THE LINES BELOW TO CONVERT APPLICATION TO HTTPS
server {
listen 80;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl default_server;
ssl_certificate /etc/nginx/conf.d/selfsigned.crt;
ssl_certificate_key /etc/nginx/conf.d/selfsigned.key;
}
Steps to Enable HTTPS¶
1. Run the set_hostname Script¶
The set_hostname script automatically configures HTTPS for your application. During execution, you will be prompted to either provide your own SSL certificate or generate a self-signed certificate. The certificates will be automatically placed in the router directory.
Refer to the Hostname Configuration section for detailed instructions on running the script.
2. Copy Certificate to Backend Container¶
For the backend service to recognize the SSL certificate, you need to copy the .crt file to the backend container's /app/certs directory.
docker cp router/selfsigned.crt dataprivacy-backend:/app/certs/
Note: If you used your own certificate with a different name, replace
selfsigned.crtwith your certificate file name.
3. Verify SSL Certificate Paths¶
Update the ssl_certificate and ssl_certificate_key paths in the default.conf file to match the names and locations of the certificate files you placed in the router directory. For example:
ssl_certificate /etc/nginx/conf.d/example.crt;
ssl_certificate_key /etc/nginx/conf.d/example.key;
4. Restart the Router¶
After making these changes, restart the router service using the following command:
docker compose restart router
5. Restart Backend Service¶
Restart the backend service to ensure it recognizes the SSL certificate:
docker compose restart dataprivacy-backend
6. Update Hostname Configuration¶
After switching to HTTPS, some applications may require reconfiguration. Set the hostname according to your DNS address. Refer to the Hostname Configuration section for details.
7. Update Keycloak Configuration¶
Update the datafocusId client in Keycloak. Follow the instructions in the Keycloak Configurations section to complete the update.
Verification¶
Once these configurations are complete, you can access Data Privacy over HTTPS at:
https://<hostname>
Success: Your application is now running securely over HTTPS. All HTTP traffic will be automatically redirected to HTTPS.
Warning: If you used a self-signed certificate, browsers will display a security warning. This is normal for self-signed certificates. For production environments, consider using a certificate from a trusted Certificate Authority.
Troubleshooting¶
If you encounter issues after enabling HTTPS:
1. Check Certificate Paths: Verify that the certificate paths in router/default.conf are correct.
-
Verify Certificate Files: Ensure the
.crtand.keyfiles exist in therouterdirectory. -
Check Backend Certificate: Confirm the certificate was copied to
/app/certs/in the backend container. -
Review Logs: Check the router and backend container logs for any errors:
Bashdocker logs router docker logs dataprivacy-backend -
Restart Services: Try restarting all services:
Bashdocker compose restart