如何远程访问自托管的Nancy服务? [英] How do I remotely access self-hosted Nancy service?

查看:140
本文介绍了如何远程访问自托管的Nancy服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的Windows服务,该服务承载一个Nancy实例以提供其内部数据的视图.在本地计算机上使用浏览器时,一切正常.我看到它可以发挥作用的观点.但是,我找不到任何无法从远程浏览器(在同一网络上)访问的原因.从远程浏览器访问仅会延迟一段时间; IE最终将显示无法显示此页面;" iPad上的Safari会在一段时间内显示部分进度栏,什么也不做.

I am creating a simple Windows service that hosts a Nancy instance to provide views of its internal data. Everything works as expected when using a browser on the local machine; I see the view that it serves up. However, I cannot find any reason why it will not access from a remote browser (on the same network). Access from a remote browser simply delays a while; IE will eventually display "This page can’t be displayed;" Safari on an iPad shows the partial progress bar for a while and does nothing.

我正在使用所有本地IP绑定,而不仅仅是本地主机. 我在此链接上使用GetUriParams()函数来发现所有本地IP地址以进行绑定. http://www.codeproject. com/Articles/694907/Embed-a-web-server-in-a-windows-service

I'm binding using all local IPs, not just localhost. I am using the GetUriParams() function at this link to discover all local IP addresses for binding. http://www.codeproject.com/Articles/694907/Embed-a-web-server-in-a-windows-service

_nancyHost = new NancyHost(GetUriParams(port));
_nancyHost.Start();

我在此页面上发现,绑定到localhost仅适用于本地访问. http://forums.asp.net/t/1881253.aspx?更多+ SelfHost +文档

I discovered at this page that binding to localhost works for local access only. http://forums.asp.net/t/1881253.aspx?More+SelfHost+Documentation

此功能发现的IP用于以太网适配器,无线适配器和先前安装VMware Player的两个VMware Network适配器.我已经尝试通过计算机名称和按原义IP远程访问以太网适配器.

The IPs that this function discovers are for Ethernet adapter, Wireless adapter, and two VMware Network adapters from a prior installation of a VMware player. I've tried the remote access both by machine name and by literal IP to the Ethernet adapter.

我将条目添加到了urlacl列表中. 我在很多地方都使用了推荐的netsh http add urlacl命令,包括以下链接:远程访问Nancy Self Host

I added entries to urlacl list. I have used the netsh http add urlacl command as recommended in many places, including at this link: Remote access to a Nancy Self Host

如果执行netsh http show urlacl,我会看到我正在使用的端口的条目.

If I perform netsh http show urlacl, I see the entry for the port I'm using.

我尝试了不同的Nancy配置 如果我为UrlReservations.CreateAutomatically设置了Nancy配置选项,我将得到安全提示,允许后,我会在netsh http show urlacl列表输出中看到所有本地IP的新条目,但仍然不允许远程访问.我还尝试了RewriteLocalHost选项true和false.

I tried different Nancy configs If I set the Nancy configuration option for UrlReservations.CreateAutomatically, I will get security prompts, which after allowing, I see new entries in netsh http show urlacl list output for all of the local IPs, but it still does not allow remote access. I also tried the RewriteLocalHost option true and false.

我尝试使用http://+:3684http://*:3684(从Uri()获取解析异常)和http://0.0.0.0:3684(从HttpListener()中从AddAllPrefixes()获取异常)启动Nancy.

I've tried starting Nancy with http://+:3684 or http://*:3684 (which gets parsing exception from Uri()) and with http://0.0.0.0:3684 (which gets exception from AddAllPrefixes() within HttpListener()).

我已将EXE添加到Windows防火墙 我创建了防火墙例外,如下所述: https://msdn.microsoft.com /en-us/library/ms733768.aspx

I added the EXE to Windows firewall I have created firewall exceptions as described here: https://msdn.microsoft.com/en-us/library/ms733768.aspx

关联的规则为同时包含TCP和UDP的每一列显示专用",公共"和任何".

The associated rule shows Private,Public and "Any" for every column with both TCP and UDP.

我尝试在不同的环境中运行Nancy.我在以下位置运行了代码:以本地系统运行的Windows服务,Visual Studio 2013调试器中的控制台应用程序以及控制台应用程序以管理员身份运行

I tried running Nancy in different environments. I've run the code in: the Windows Service running as Local System, a console app within Visual Studio 2013 debugger, and the console app Run As Administrator.

我以为这是一个简单的安全设置,但是我已经搜寻并搜索各种内容几天了.

I imagine it's a simple security setting, but I've googled and searched and tried various things for a couple of days now.

我想念什么?

推荐答案

此答案提供了我需要的线索. https://stackoverflow.com/a/21364604/1139376

This answer provided the clue I needed. https://stackoverflow.com/a/21364604/1139376

这是因为HttpListener构建在http.sys之上,它将在您代表程序指定的端口上进行监听.

This is because HttpListener is built on top of http.sys which will listen on the port you specified on behalf of your program.

这不是我的EXE进行的实际监听.我需要做的就是向Windows防火墙中为系统"程序和我正在使用的特定TCP端口添加一个传入规则.允许远程访问.

It wasn't my EXE doing the actual listening. All I needed to do was to add an Incoming rule to the Windows Firewall set for the "System" program and the specific TCP port I'm using. That allowed remote access.

这篇关于如何远程访问自托管的Nancy服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆