SSL: NancyFx Selfhost Mono Linux (pi)

纵然是瞬间 提交于 2019-12-04 07:40:30

I have no knowledge of PI at all, but I assume it's not much different than hosting on any other variant of linux.

There's two ways. The first is documented on the Wiki:

https://github.com/NancyFx/Nancy/wiki/Hosting-Nancy-with-Nginx-on-Ubuntu

Basically the idea is to use nginx web server to delegate calls to a self-hosted app.

The second is to use nginx, with mono-fastcgi-server4 to handle the requests. This works more like a traditional website rather than a website delegating requests to another service.

I've blogged the process here:

http://www.philliphaydon.com/2013/06/setting-up-mono-on-nginx/

http://www.philliphaydon.com/2013/07/setting-up-a-nancyfx-website/

In theory the first solution should allow you to use OWIN and host other things such as SignalR, while my solution does not, since nginx doesn't support integrated pipeline there's no way for OWIN to work, and I haven't successfully got SignalR to work with it.

RhinoDevel

Use httpcfg to bind your certificate to a port, e.g.:

httpcfg -add -cert my_certificate.cer -pvk my_privatekey.pvk -port 443

But unfortunately there seems to be a problem with current Mono version requiring client certificates, see:

https://github.com/mono/mono/pull/1202

and (more recent follow-up)

https://github.com/mono/mono/pull/2817

The last Mono version that works (I tested this) is 3.10.0 (which shouldn't be used in production environment, because of missing security updates).

Take a look at my answer to this question for a way to use a recent Mono version by patching the source code and compiling it yourself.

The internet is still mostly littered with 2016-ish articles and comments about httpListener bug with SSL in Mono (and this causes problems for the OP's question about Nancy on Linux). The problem may have been resolved in the latest Mono releases, but I have not seen that information. However, it may not even matter, because many users who looked into this seem to report that using Nginx as a frontend and as reverse-proxy is a much better solution anyway.

The primary question discussing this problem can be found here: Mono HttpListener client certificate

The Nancy instructions for hosting with Nginx can be found here: https://github.com/NancyFx/Nancy/wiki/Hosting-Nancy-with-Nginx-on-Ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!