How configure Nancyfx with https

2019-08-06 04:57发布

I have register ssl certificates for server. Insert all certs to /usr/local/share/ca-certificates/ and make update-ca-certificates.

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
        }

enter image description here

标签: ssl nancy
1条回答
不美不萌又怎样
2楼-- · 2019-08-06 05:41

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:

  1. Set up Nancy Console App
  2. Set up and configure ssl enabled web server to pass requests to your nancy app
  3. Use some control app to make sure that both of them alive all the time
查看更多
登录 后发表回答