- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Docker 容器在 Ubuntu (18.04.3 LTS) 服务器上运行基于 ASP.NET Core 3.1 框架的应用程序。
我创建了以下 docker-compose.yml 文件,以便能够在我的服务器上运行 nginx-proxy 和 private_image_name 镜像。显然,nginx-proxy 是一个代理服务器,它将作为将来自网络的流量路由到我的其他正在运行的镜像的代理。我关注了article用于 nginx-proxy
设置。
version: '3.4'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- certificates:/etc/certificates
private_image_name:
image: private_image_name:latest
container_name: private_image_name
depends_on:
- nginx-proxy
environment:
- VIRTUAL_HOST=sub.domain-example.com
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- 51736:80
- 44344:443
volumes:
- storage:/storage
- /var/run/docker.sock:/tmp/docker.sock:ro
- certificates:/etc/certificates
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
volumes:
storage:
certificates:
networks:
default:
external:
name: nginx-proxy
secrets:
server.cert:
file: ./server.cert
server.key:
file: ./server.key
server.cert
和 server.key
文件都存储在 /etc/certificates
中。这两个文件都是使用以下命令创建的
sudo openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=US/ST=CA/L=SF/O=Docker-demo/CN=app.example.org" -keyout server.key -out server.cert
我尝试通过执行docker-composer up
来运行我的两个镜像。但是,nginx-proxy
没有出现任何问题,而 private_image_name
无法运行。以下是我在运行 private_image_name
尝试启动时得到的结果
**WARNING**: The APPDATA variable is not set. Defaulting to a blank string.
Recreating private_image ... done
Attaching to private_image
private_image | crit: Microsoft.AspNetCore.Server.Kestrel[0]
private_image | Unable to start Kestrel.
private_image | System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
private_image | To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
private_image | For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
private_image | at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
private_image | at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
private_image | at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
private_image | at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
private_image | at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
private_image | Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
private_image | To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
private_image | For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
private_image | at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
private_image | at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
private_image | at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
private_image | at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
private_image | at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
private_image | at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
private_image | at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
private_image | at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
private_image | at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
private_image | at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
private_image | at private_image.Program.Main(String[] args) in /src/private_image/Program.cs:line 17
private_image exited with code 139
命令 dotnet dev-certs https --trust
仅适用于 Windows 和 macOS。
问题
如何在 Ubuntu 服务器上解决此问题?如何正确地将 SSL 证书附加到 docker 镜像?
此外,当我转到http://server-ip-address时或http://sub.domain-example.com我明白
503 Service Temporarily Unavailable nginx/1.17.5
当我访问https://server-ip-address时或https://sub.domain-example.com我明白
Unable to connect.
最佳答案
一旦您在 nginx 中设置了证书,我就认为在 asp.net core 容器中启用它没有任何意义,因为您的 docker 网络将通过 nginx 对公众可见。
要禁用 Kestrel Https 监听,只需从以下代码中删除 443 端口:
- ASPNETCORE_URLS=https://+:443;http://+:80
替换为:
- ASPNETCORE_URLS=http://+:80
关于Docker镜像: Unable to configure HTTPS endpoint.没有指定服务器证书,找不到默认的开发者证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59743735/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!