在HTTPS上运行docker服务 [英] Run docker service on HTTPS

查看:64
本文介绍了在HTTPS上运行docker服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我通过使用以下文件运行一个简单的Docker容器。

Currently, I run a simple docker container by using the following files.

DockerFile

DockerFile

FROM microsoft/aspnet:4.7.1
WORKDIR /inetpub/wwwroot
EXPOSE 80
COPY index.html .

docker-compose.yml

docker-compose.yml

version: '3.4'

services:

testapp:
  image: mytestapp:${TAG:-latest}
build:
  context: .
  dockerfile: Dockerfile

docker-compose.override.yml

docker-compose.override.yml

version: '3.4'

services:
  testapp:
   ports:
    - "9091:80"

我使用Windows映像通过以下命令创建容器,并且可以访问通过 http:// localhost:9091 /

I use windows image to create my container by using the following command and I can access it by http://localhost:9091/.

docker-compose -f docker-compose.yml -f docker-compose.override.yml build

我想使用HTTPS而不是http来访问我的应用程序。

I want to access my app by using HTTPS instead of http.

我需要遵循哪些步骤?

推荐答案


  1. 您需要配置Web服务器(在docker应用程序内部)以启用HTTPS。

  2. 在docker上打开SSL端口(443)

  1. You need to configure your web server (inside the docker application) to enable HTTPS.
  2. Open SSL port (443) on docker


  • 您可以考虑使用NGINX作为Web服务器的反向代理,并在nginx中配置SSL

  • 如果这是一个公共站点,则可以查看letsencrypt为您的域获取免费的SSL证书。

这篇关于在HTTPS上运行docker服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆