Hello @Salamaia,Leandro ,
Thanks for posting your query on Microsoft QnA. apologies for the delay in response.
As per my understanding, you want to enable HTTPS (SSL) on your container. To do this, as you mentioned, you would need to generate a certificate ssl.crt and a key ssl.key using the below openssl
commands.
The below command is to create a certificate rquest (.csr file) in the local working directory.
openssl req -new -newkey rsa:2048 -nodes -keyout ssl.key -out ssl.csr
Here, you will prompted to add identification information. Please remember for Common Name , enter the FQDN associated with the container. then, run the below command to create the self-signed certificate file.
openssl x509 -req -days 365 -in ssl.csr -signkey ssl.key -out ssl.crt
Typically, for a web application, I would use an Nginx reverse proxy and configure it to use SSL/TLS. You will first need to set up the FQDN (for example - mycontainer.eastus.azurecontainer.io) for the container using --dns-name-label
to point the domain name to the container IP.
Then, you will have to edit the nginx configuration file which is present within the container add add the domain name under the server_name, and then set the correct port for your application under proxy_pass.
Something like this :
server {
listen 443 ssl;
server_name mycontainer.eastus.azurecontainer.io;
location / {
proxy_pass http://localhost:80; #replace port if app listens on port other than 80
}
}
For the detailed steps, I will recommend you to follow this tutorial.
Reference links:
https://stackoverflow.com/questions/40867727/how-to-assign-domain-names-to-containers-in-docker
https://forums.docker.com/t/setup-local-domain-and-ssl-for-php-apache-container/116015
Please do let me know if this helps.
----------------------
Please don't forget to "Accept as Answer" and "Upvote" if you think my response was helpful, so that it can help others in the community looking for help on similar issues.