• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

银河麒麟服务器v10 sp1 部署.Net6.0 http httphotoshop

武飞扬头像
csdn_aspnet
帮助1

参考微软官网:ASP.NET Core 中的 Kestrel Web 服务器 | Microsoft Learn

为 ASP.NET Core Kestrel Web 服务器配置终结点 | Microsoft Learn

注意:使用此篇文章配置,请将之前文中的appsettings.json中配置"urls": "http://*:8061" 注释。

json内容,选择适合自己的即可:

{
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      },
      "HttpsInlineCertFile": {
        "Url": "https://localhost:5001",
        "Certificate": {
          "Path": "<path to .pfx file>",
          "Password": "<certificate password>"
        }
      },
      "HttpsInlineCertStore": {
        "Url": "https://localhost:5002",
        "Certificate": {
          "Subject": "<subject; required>",
          "Store": "<certificate store; required>",
          "Location": "<location; defaults to CurrentUser>",
          "AllowInvalid": "<true or false; defaults to false>"
        }
      },
      "HttpsDefaultCert": {
        "Url": "https://localhost:5003"
      },
      "Https": {
        "Url": "https://*:5004",
        "Certificate": {
          "Path": "<path to .pfx file>",
          "Password": "<certificate password>"
        }
      }
    },
    "Certificates": {
      "Default": {
        "Path": "<path to .pfx file>",
        "Password": "<certificate password>"
      }
    }
  }
}

本文使用的是pfx节点配置。 

在appsettings.json中新增配置:

{
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://xxx:8061"
      },
      "HttpsInlineCertFile": {
        "Url": "https://xxx:8062",
        "Certificate": {
          "Path": "/usr/local/xxx.pfx",
          "Password": "xxx@2023"
        }
      }
    }
  }
}

本文在windows配置示例如下:

学新通

上面示例部署到银河麒麟V10 SP1时,更换银河麒麟V10服务器pfx证书的具体路径。

在Program.cs中读取Kestrel配置节点:

学新通

代码如下: 

//部署银河麒麟V10 SP1 读取appsettings.json中Kestrel配置
            app.Configuration.Get<WebHostBuilder>().ConfigureKestrel(options =>
            {
                // 长度最好不要设置 null
                options.Limits.MaxRequestBodySize = 1024 * 1024 * 600;
                //获取或设置最大打开的连接数
                options.Limits.MaxConcurrentConnections = 1024;
                //获取或设置最大打开、升级的连接数
                //升级的连接是已从 HTTP 切换到另一个协议(如 WebSocket)的连接。
                //连接升级后,不会计入 MaxConcurrentConnections 限制
                options.Limits.MaxConcurrentUpgradedConnections = 500;

            })
            //银河麒麟V10 SP1 解决无法访问静态文件问题
            .UseContentRoot(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot"));

 重新发布net6项目,并重新启动dotnet6服务即可正常访问:

https访问: 

学新通

http访问:

学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgejicb
系列文章
更多 icon
同类精品
更多 icon
继续加载