【问题标题】:Fresh dotnet new mvc project @ Linux - Failed to authenticate HTTPS connectionFresh dotnet new mvc 项目@Linux - 无法验证 HTTPS 连接
【发布时间】:2019-04-27 00:41:33
【问题描述】:

我刚刚用dotnet new mvc创建了一个新项目,但是在远程连接到那个网页之后(我正在使用nginx来实现反向代理)

有一个异常被提出

dbug:HttpsConnectionAdapter[1] 无法验证 HTTPS 连接。 System.IO.IOException:由于意外的数据包格式,握手失败。 在 System.Net.Security.SslState.StartReadFrame(字节 [] 缓冲区,Int32 读取字节,AsyncProtocolRequest asyncRequest) 在 System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest) --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Net.Security.SslState.ThrowIfExceptional() 在 System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResultlazyResult) 在 System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult 结果) 在 System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult) 在 System.Net.Security.SslStream.c.b__51_1(IAsyncResult iar) 在 System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext 上下文)

有人知道可能是什么原因吗?

Nginx 状态:

● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-11-24 23:35:25 CET; 6s ago
Docs: man:nginx(8)
Process: 16378 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 16383 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 16381 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 16386 (nginx)
Tasks: 2 (limit: 4915)
Memory: 2.9M
CPU: 47ms
CGroup: /system.slice/nginx.service
   ├─16386 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
   └─16387 nginx: worker process

我的 nginx -> 站点可用 -> default.txt

server {
    listen        80;
    server_name   example.com *.example.com;
    location / {
        proxy_pass         http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

 dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.402
 Commit:    3599f217f4

Runtime Environment:
 OS Name:     debian
 OS Version:  9
 OS Platform: Linux
 RID:         debian.9-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.402/

Host (useful for support):
  Version: 2.1.4
  Commit:  85255dde3e

.NET Core SDKs installed:
  2.1.402 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.                                                                                                                                                             All]
  Microsoft.AspNetCore.App 2.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.                                                                                                                                                             App]
  Microsoft.NETCore.App 2.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

【问题讨论】:

    标签: c# nginx asp.net-core asp.net-core-mvc debian


    【解决方案1】:

    解决方案:

    在其他文件 nginx 站点文件中:sites-enabled/default 我使用了这个配置:

    server {
        listen        80;
        server_name   example.com *.example.com;
        location / {
            proxy_pass         http://localhost:5001;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection keep-alive;
            proxy_set_header   Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Proto $scheme;
        }
    }
    

    解决方案是将端口 5001 更改为 5000

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-31
      • 2019-10-06
      • 1970-01-01
      • 2020-12-18
      • 2022-01-01
      • 1970-01-01
      • 2018-01-28
      相关资源
      最近更新 更多