将SSL绑定到Azure容器实例

时间:2019-11-29 10:47:39

标签: azure ssl azure-container-instances azure-container-registry

我已经创建了节点js api,并使用注册表将其托管在Azure容器实例中。我正在使用FQDN使用我的API。现在,我想将SSL证书绑定到该实例。有什么办法吗?我搜索了解决方案,但未找到任何解决方案。

1 个答案:

答案 0 :(得分:0)

您可以使用应用程序容器和运行SSL提供程序的sidecar容器创建容器组。

根据this document,您将执行以下操作:

  • Create a self-signed certificate。对于生产方案,应从证书颁发机构获取证书。
  • 配置Nginx以使用SSL。您为Nginx创建一个配置文件以使用SSL。对Nginx配置文件,SSL证书和SSL密钥进行Base64编码。然后,在用于部署容器组的YAML文件中输入编码后的内容。
  • Deploy container group通过在YAML文件中指定容器配置。

例如,您可以编辑以下YAML文件以满足您的要求。

api-version: 2018-10-01
location: westus
name: app-with-ssl
properties:
  containers:
  - name: nginx-with-ssl
    properties:
      image: nginx
      ports:
      - port: 443
        protocol: TCP
      resources:
        requests:
          cpu: 1.0
          memoryInGB: 1.5
      volumeMounts:
      - name: nginx-config
        mountPath: /etc/nginx
  - name: my-app
    properties:
      image: mcr.microsoft.com/azuredocs/aci-helloworld
      ports:
      - port: 80
        protocol: TCP
      resources:
        requests:
          cpu: 1.0
          memoryInGB: 1.5
  volumes:
  - secret:
      ssl.crt: <Enter contents of base64-ssl.crt here>
      ssl.key: <Enter contents of base64-ssl.key here>
      nginx.conf: <Enter contents of base64-nginx.conf here>
    name: nginx-config
  ipAddress:
    ports:
    - port: 443
      protocol: TCP
    type: Public
  osType: Linux
tags: null
type: Microsoft.ContainerInstance/containerGroups