azure container instance running on private network with domain

Salamaia,Leandro 1 Reputation point
2022-02-21T13:24:54.647+00:00

I have an ACI running on a private network, there I have my application, my application needs to run on HTTPS protocol for that I need a certificate but I can't add a domain to my container to be able to generate the certificate

Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
387 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
635 questions
{count} votes

1 answer

Sort by: Most helpful
  1. srbhatta-MSFT 8,546 Reputation points Microsoft Employee
    2022-02-25T10:16:40.94+00:00

    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.

    0 comments No comments