远程访问Nancy Self Host [英] Remote access to a Nancy Self Host

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

问题描述

我正在创建一个Nancy模块,该模块最终将托管在Windows Service内部.我目前正在WPF测试应用程序中运行它.要启动Nancy托管,我正在使用Nancy.Hosting.Self并调用:

I am creating a Nancy Module that will eventually be hosted inside of a Windows Service. I am currently running it inside of a WPF test application. To start the Nancy hosting, I am using Nancy.Hosting.Self and calling:

nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8080"));
nancyHost.Start();

在本地计算机上,我可以转到Web浏览器并通过在地址中输入 http://localhost:8080 来访问我的模块酒吧.

On my local machine I am able to go to a web browser and access my module by entering http://localhost:8080 into the address bar.

如果我转到另一台机器,则无法访问该服务.我的Windows防火墙已关闭.

If I go to another machine I am not able to access the service. My Windows Firewall is turned off.

如果我使用baseUri中的localhost以外的任何其他资源启动托管,则在调用nancyHost.Start();时会收到访问被拒绝"异常.

If I start the hosting with anything other than localhost in the baseUri, I get an "access denied" exception upon calling nancyHost.Start();

有什么我想念的吗?只要我知道进行托管的计算机的IP:Port,是否应该可以从任何计算机访问Nancy模块?我需要了解任何类型的主机标头"吗?

Is there something that I am missing? Should I be able to access the Nancy module from any machine as long as I know the IP:Port to the machine doing the hosting? Is there any type of "host headering" that I need to be aware of?

感谢您的帮助.

推荐答案

Windows将阻止您未经许可就监听端口.您可以以管理员身份运行进程,也可以使用"netsh"添加权限:

Windows will prevent you from listening on ports without permission. You can either run your process as administrator, or add permission using "netsh":

netsh http add urlacl url = http://+:8080/app user = domain \ user

netsh http add urlacl url=http://+:8080/app user=domain\user

"+"是通配符,因此它可以侦听任何IP.

The "+" is a wildcard so it can listen on any IP.

通常,您将在安装过程中处理后者,因此您可能希望以admin身份运行以进行调试,然后确保安装程序设置了相关权限.

Normally you'd handle the latter during installation, so you may want to run as admin to debug, then make sure your installer sets the relevant permissions.

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

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