如何使用https配置Nancyfx [英] How configure Nancyfx with https
问题描述
我已经为服务器注册了ssl证书.将所有证书插入/usr/local/share/ca-certificates/
并制作update-ca-certificates
.
I have register ssl certificates for server. Insert all certs to /usr/local/share/ca-certificates/
and make update-ca-certificates
.
当应用启动时,我跟随URL https _//www.site.org:443,但未加载.
When app start, I follow by url https_//www.site.org:443 but its not loading.
static void Main(string[] args)
{
var uri = "https://localhost:443";
var host = new NancyHost(new Uri(uri));
host.Start(); // start hosting
if (args.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
{
Thread.Sleep(Timeout.Infinite);
}
else
{
Trictionary.initilizeDic();
Console.ReadKey();
}
host.Stop(); // stop hosting
}
推荐答案
Nancy控制台托管本身不支持ssl,因此,要拥有ssl,您需要运行另一台支持ssl的Web服务器.我不知道您使用的是哪个操作系统,但是例如,它是ubuntu.在ubuntu上,您可以使用ssl运行nginx,例如官方文档解释了如何设置nginx和南希组合. 您的基本情况是:
Nancy console hosting doesn't support ssl itself, so in order to have ssl, you need to run another web server, which does support ssl. I don't know which OS you use, but let's say it is ubuntu for example. On ubuntu you can run nginx with ssl, like described here and then use proxy_pass to send decrypted request to your console app. Official documentation explains how to set up nginx and nancy combination. Your basic scenario would be:
- 设置Nancy Console应用
- 设置并配置启用ssl的网络服务器,以将请求传递到您的nancy应用
- 使用一些控制应用程序以确保两个人都一直活着
这篇关于如何使用https配置Nancyfx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!