如何在 IIS Express 中启用外部请求?

发布于 2024-09-10 16:53:21 字数 174 浏览 3 评论 0 原文

如何在 IIS Express 中启用远程请求? Scott Guthrie 写道这是可能的,但是他没有说怎么做。

How can I enable remote requests in IIS Express? Scott Guthrie wrote that is possible but he didn't say how.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(28

一向肩并 2024-09-17 16:53:21

IIS 团队网站上有一篇博客文章,现在解释如何在 IIS Express 上启用远程连接。以下是该帖子的相关部分总结:

在 Vista 和 Win7 上,从管理提示符运行以下命令:

netsh http add urlacl url=http://vaidesg:8080/ user=everyone

对于 XP,首先安装 Windows XP Service Pack 2 支持工具。然后从管理提示符运行以下命令:

httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(A;;GX;;;WD)

There's a blog post up on the IIS team site now explaining how to enable remote connections on IIS Express. Here is the pertinent part of that post summarized:

On Vista and Win7, run the following command from an administrative prompt:

netsh http add urlacl url=http://vaidesg:8080/ user=everyone

For XP, first install Windows XP Service Pack 2 Support Tools. Then run the following command from an administrative prompt:

httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(A;;GX;;;WD)

短叹 2024-09-17 16:53:21

您可能需要进行三项更改。

  1. 告诉 IIS Express 本身绑定到所有 IP 地址和主机名。在您的 .config 文件中。通常:
    • 对比 2015 年:
      $(solutionDir)\.vs\config\applicationhost.config
    • < VS 2015:%userprofile%\My Documents\IISExpress\config\applicationhost.config
    • 与 2015 年相比

找到站点的绑定元素,然后添加

    <binding protocol="http" bindingInformation="*:8080:*" />
  1. 名为“http.sys”的 Windows 位安装程序。以管理员身份运行以下命令:
    netsh http add urlacl url=http://*:8080/ user=everyone

其中 everyone 是 Windows 组。对于带有空格的组(如“Tout le monde”)使用双引号。

  1. 允许 IIS Express 通过 Windows 防火墙。

    <块引用>

    启动/具有高级安全性的 Windows 防火墙/入站规则/新规则...

    程序%ProgramFiles%\IIS Express\iisexpress.exe
    或端口 8080 TCP

现在,当您启动 iisexpress.exe 时,您应该会看到一条消息,例如

已成功注册站点“hello world”应用程序“/”的 URL“http://*:8080/”

There are three changes you might need to make.

  1. Tell IIS Express itself to bind to all ip addresses and hostnames. In your .config file. Typically:
    • VS 2015:
      $(solutionDir)\.vs\config\applicationhost.config
    • < VS 2015: %userprofile%\My Documents\IISExpress\config\applicationhost.config

Find your site's binding element, and add

    <binding protocol="http" bindingInformation="*:8080:*" />
  1. Setup the bit of Windows called 'http.sys'. As an administrator, run the command:
    netsh http add urlacl url=http://*:8080/ user=everyone

Where everyone is a windows group. Use double quotes for groups with spaces like "Tout le monde".

  1. Allow IIS Express through Windows firewall.

    Start / Windows Firewall with Advanced Security / Inbound Rules / New Rule...

    Program %ProgramFiles%\IIS Express\iisexpress.exe
    OR Port 8080 TCP

Now when you start iisexpress.exe you should see a message such as

Successfully registered URL "http://*:8080/" for site "hello world" application "/"

残月升风 2024-09-17 16:53:21

在我找到 iisexpress-proxy 之前,一切都对我不起作用。

以管理员身份打开命令提示符,然后运行

npm install -g iisexpress-proxy

,然后

iisexpress-proxy 51123 to 81

假设您的 Visual Studio 项目在 localhost:51123 上打开,并且您想要访问外部 IP 地址 xxxx:81

编辑:我当前正在使用 ngrok

Nothing worked for me until I found iisexpress-proxy.

Open command prompt as administrator, then run

npm install -g iisexpress-proxy

then

iisexpress-proxy 51123 to 81

assuming your Visual Studio project opens on localhost:51123 and you want to access on external IP address x.x.x.x:81

Edit: I am currently using ngrok

千紇 2024-09-17 16:53:21

我记得几个月前尝试此工作流程时遇到了同样的问题。

这就是为什么我专门为这种情况编写了一个简单的代理实用程序: https://github.com/icflorescu/iisexpress-proxy< /a>.

使用 IIS Express 代理,一切都变得非常简单 - 无需“netsh http add urlacl url=vaidesg:8080/” user=everyone”或者搞乱你的“applicationhost.config”。

只需在命令提示符中发出以下命令:

iisexpress-proxy 8080 to 3000

...然后您就可以将远程设备指向http://vaidesg: 3000。

大多数时候越简单越好。

I remember running into the same problems while trying this workflow a few months ago.

Which is why I wrote a simple proxy utility specifically for this kind of scenario: https://github.com/icflorescu/iisexpress-proxy.

Using the IIS Express Proxy, it all becomes quite simple – no need to “netsh http add urlacl url=vaidesg:8080/ user=everyone” or to mess up with your “applicationhost.config”.

Just issue this in command prompt:

iisexpress-proxy 8080 to 3000

…and then you can point your remote devices to http://vaidesg:3000.

Most of the times simpler IS better.

戈亓 2024-09-17 16:53:21

如果您使用 Visual Studio,请按照以下步骤通过 IP 地址访问 IIS-Express:

  1. 获取主机 IP 地址:在 Windows 命令行中ipconfig

  2. GoTo

    $(SolutionDir)\.vs\config\applicationHost.config
    
  3. 查找

    <站点名称=“WebApplication3”id=“2”>
       <应用程序路径=“/”applicationPool=“Clr4IntegratedAppPool”>
          />
       
       <绑定>
         <绑定协议=“http”绑定信息=“*:62549:localhost”/>
       
    
    
  4. 添加:
    <绑定协议="http" bindingInformation="*:62549:192.168.178.108"/>
    与您的 IP 地址

  5. 使用管理员权限运行 Visual Studio,一切都应该正常

  6. 查看 Andrii 的帖子如何配置防火墙:此处

If you're working with Visual Studio then follow these steps to access the IIS-Express over IP-Adress:

  1. Get your host IP-Adress: ipconfig in Windows Command Line

  2. GoTo

    $(SolutionDir)\.vs\config\applicationHost.config
    
  3. Find

    <site name="WebApplication3" id="2">
       <application path="/" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="C:\Users\user.name\Source\Repos\protoype-one\WebApplication3" />
       </application>
       <bindings>
         <binding protocol="http" bindingInformation="*:62549:localhost" />
       </bindings>
    </site>
    
  4. Add:
    <binding protocol="http" bindingInformation="*:62549:192.168.178.108"/>
    with your IP-Adress

  5. Run your Visual Studio with Administrator rights and everything should work

  6. See post from Andrii how to configure Firewall: here

季末如歌 2024-09-17 16:53:21

作为旁注:

netsh http add urlacl url=http://vaidesg:8080/ user=everyone

这仅适用于英文版本的 Windows。如果您使用本地化版本,则必须将“everyone”替换为其他内容,例如:

  • 使用荷兰语版本时为“Iedereen” 使用
  • 德语版本时为“Jeder”
  • 使用匈牙利语版本时为“Mindenki”

否则您将得到错误(创建 SDDL 失败,错误:1332)

As a sidenote to this:

netsh http add urlacl url=http://vaidesg:8080/ user=everyone

This will only work on English versions of Windows. If you are using a localized version you have to replace "everyone" with something else, for example:

  • "Iedereen" when using a Dutch version
  • "Jeder" when using a German version
  • "Mindenki" when using a Hungarian version

Otherwise you will get an error (Create SDDL failed, Error: 1332)

箹锭⒈辈孓 2024-09-17 16:53:21

Scott Hanselman 的 使用 IISExpress 在开发时使用 SSL 更容易 是一个很好的资源。

您所关注的是让 IIS Express 通过端口 80 向外部提供服务部分

A good resource is Working with SSL at Development Time is easier with IISExpress by Scott Hanselman.

What you're after is the section Getting IIS Express to serve externally over Port 80

调妓 2024-09-17 16:53:21

我通过在 Visual Studio Professional 2015 中安装“Conveyor by Keyoti”解决了这个问题。Conveyor 生成一个带有启用外部请求的端口 (45455) 的远程地址(您的 IP)。示例:

enter图片说明此处

Conveyor 允许您从网络上的外部平板电脑和手机或 Android 模拟器测试 Web 应用程序(不带 http://10.0.2.2:

步骤位于以下链接中:

https://marketplace.visualstudio.com /items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

I solved it with the installation of "Conveyor by Keyoti" in Visual Studio Professional 2015. Conveyor generate a REMOTE address (your IP) with a port (45455) that enable external request. Example:

enter image description here

Conveyor allows you test web applications from from external tablets and phones on your network or from Android emulators (without http://10.0.2.2:<hostport>)

The steps are in the following link :

https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

时光倒影 2024-09-17 16:53:21

结合此线程中的答案,这就是我修复它的方法(Visual Studio 2019):

  1. 以管理员身份启动 Visual Studio 并像平常一样运行您的 Web 服务。

  2. 在任务栏上找到 IIS Express 图标,右键单击它,然后单击“显示所有应用程序”。

  3. 选择您的 Web 服务并记下下面显示的配置路径。单击配置文件将其打开进行编辑。

  4. 在此配置文件中找到您的网络服务(例如搜索您的端口),然后找到如下行:
    *:你的端口:localhost

  5. 在后面添加一个新行,如下所示:

    您的端口*

在这种情况下,无需创建绑定将来可能会更改的特定 IP 地址。

我希望这对那里的人有帮助。

Combining answers in this thread, this is how I fixed it(Visual Studio 2019):

  1. Start Visual Studio as an Administrator and Run your Web Service as you normally do.

  2. Find IIS Express icon on the taskbar, right click on it then click "Show All Applications".

  3. Select your Web Service and note the config path displayed below. Click on the config file to open it for editing.

  4. Find your web service(example search for your port) in this config file then find a line like this:
    *:yourport:localhost

  5. Add a new line after that like this:

    :yourport:*

In this case no need to create bindings with specific ip address which could change in the future.

I hope this helps someone out there.

已下线请稍等 2024-09-17 16:53:21

这就是我使用 Visual Studio 2015 对 Windows 10 所做的操作,以启用远程访问(使用 http 和 https):

第一步是将您的应用程序绑定到您的内部 IP 地址。运行cmd -> ipconfig 获取地址。打开文件 /{项目文件夹}/.vs/config/applicationhost.config 并向下滚动,直到找到如下内容:

<site name="Project.Web" id="2">
    <application path="/">
        <virtualDirectory path="/" physicalPath="C:\Project\Project.Web" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:12345:localhost" />
    </bindings>
</site>

bindings 下添加两个新绑定。如果愿意,您也可以使用 HTTPS:

<binding protocol="http" bindingInformation="*:12345:192.168.1.15" />
<binding protocol="https" bindingInformation="*:44300:192.168.1.15" />

将以下规则添加到防火墙,以管理员身份打开新的 cmd 提示符并运行以下命令:

netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=12345 profile=private remoteip=localsubnet action=allow

netsh advfirewall firewall add rule name="IISExpressWebHttps" dir=in protocol=tcp localport=44300 profile=private remoteip=localsubnet action=allow

现在以 管理员 身份启动 Visual Studio >。右键单击 Web 项目项目文件并选择 Properties。转到Web 选项卡,然后单击创建虚拟目录。如果 Visual Studio 不以管理员身份运行,这可能会失败。现在一切都应该可以了。

输入图像描述这里

This is what I did for Windows 10 with Visual Studio 2015 to enable remote access, both with http and https:

First step is to bind your application to your internal IP address. Run cmd -> ipconfig to get the address. Open the file /{project folder}/.vs/config/applicationhost.config and scroll down until you find something like this:

<site name="Project.Web" id="2">
    <application path="/">
        <virtualDirectory path="/" physicalPath="C:\Project\Project.Web" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:12345:localhost" />
    </bindings>
</site>

Add two new bindings under bindings. You can use HTTPS as well if you like:

<binding protocol="http" bindingInformation="*:12345:192.168.1.15" />
<binding protocol="https" bindingInformation="*:44300:192.168.1.15" />

Add the following rule to your firewall, open a new cmd prompt as admin and run the following commands:

netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=12345 profile=private remoteip=localsubnet action=allow

netsh advfirewall firewall add rule name="IISExpressWebHttps" dir=in protocol=tcp localport=44300 profile=private remoteip=localsubnet action=allow

Now start Visual Studio as Administrator. Right click the web projects project file and select Properties. Go to the Web tab, and click Create Virtual Directory. If Visual Studio is not run as Administrator this will probably fail. Now everything should work.

enter image description here

任性一次 2024-09-17 16:53:21

对我有帮助的是右键单击“IISExpress”图标,“显示所有应用程序”。然后选择该网站,我看到它使用哪个 aplicationhost.config,并且更正进行得非常完美。

IISExpress 配置

What helped me, was right clicking the 'IISExpress' icon, 'Show All applications'. Then selecting the website and I saw which aplicationhost.config it uses, and the the correction went perfectly.

IISExpress configuration

一场信仰旅途 2024-09-17 16:53:21

我发现的最简单、最酷的方法是使用(设置需要 2 分钟):

https://ngrok.com/

它将与本地主机上运行的任何东西一起工作。只需注册,运行一点可执行文件,无论您在本地主机上运行什么,都会获得可以从任何地方访问的公共 URL。

这非常适合向远程团队成员展示内容,无需摆弄 IIS 设置或防火墙。想要停止访问只需终止可执行文件即可。

ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ngrok http -host-header=localhost 89230

假设 89230 是您的 IIS Express 端口

即使在免费计划中您也可以运行多个端口

The simplest and the coolest way I found was to use (it takes 2 minutes to setup):

https://ngrok.com/

It will work with anything running on localhost. Just signup, run little excutable and whatever you run on localhost gets public URL you can access from anywhere.

This is good for showing stuff to your remote team mates, no fiddling with IIS setup or firewalls. Want to stop access just terminate executable.

ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ngrok http -host-header=localhost 89230

assuming that 89230 is your IIS Express port

You can also run multiple ports even on free plan

ぃ双果 2024-09-17 16:53:21

如果您已尝试 Colonel Panic 的答案,但在 Visual Studio 中不起作用,请尝试以下操作:

附加另一个 <在 IIS Express 配置中绑定/>

<bindings>
    <binding protocol="http" bindingInformation="*:8080:localhost" />
    <binding protocol="http" bindingInformation="*:8080:hostname" />
</bindings>

最后,您必须以管理员身份运行 Visual Studio

If you have tried Colonel Panic's answer but doesn't work in Visual Studio, try this:

Append another <binding /> in your IIS Express config

<bindings>
    <binding protocol="http" bindingInformation="*:8080:localhost" />
    <binding protocol="http" bindingInformation="*:8080:hostname" />
</bindings>

Finally, you have to run Visual Studio as Admin

饮湿 2024-09-17 16:53:21

此问题的公认答案是使 IIS Express 与 webmatrix 配合使用的指南。我发现本指南在尝试让它与 VS 2010 一起工作时更有用。

我只是按照步骤 3 和 3 进行操作。 4(以管理员身份运行 IIS Express)并且必须暂时禁用我的防火墙才能使其正常工作。

The accepted answer to this question is a guide for getting IIS Express to work with webmatrix. I found this guide more useful when trying to get it to work with VS 2010.

I just followed steps 3 & 4 (running IIS Express as administrator) and had to temporarily disable my firewall to get it working.

意中人 2024-09-17 16:53:21

您可以尝试设置端口转发,而不是尝试修改 IIS Express 配置、添加新的 HTTP.sys 规则或以管理员身份运行 Visual Studio。

基本上,您需要将网站运行的 IP:PORT 转发到计算机上的其他空闲端口,但位于外部网络适配器上,而不是本地主机上。

问题是 IIS Express(至少在 Windows 10 上)绑定到 [::1]:port 意味着它侦听 IPv6 端口。你需要考虑到这一点。

这是我完成这项工作的方法 - http://programmingflow .com/2017/02/25/iis-express-on-external-ip.html

希望有帮助。

You may try setting up port forwarding instead of trying to modify your IIS Express config, adding new HTTP.sys rules or running Visual Studio as an Admin.

Basically you need to forward the IP:PORT your website runs at to some other free port on your machine but on the external network adapter, not localhost.

The thing is that IIS Express (at least on Windows 10) binds to [::1]:port meaning it listens on IPv6 port. You need to take this into account.

Here is how I made this work - http://programmingflow.com/2017/02/25/iis-express-on-external-ip.html

Hope it helps.

橪书 2024-09-17 16:53:21

我在 Win 8.1 和外部请求中使用 IIS Express 时遇到一些问题。

我按照以下步骤调试外部请求:

  1. 安装 IIS
  2. 配置 Visual Studio 以使用本地 IIS(Web 项目中的页面属性)
  3. 在 IIS 中创建一个专用的 AppPool 以与我的应用程序一起使用
  4. 在我的项目中,我正在使用 Oracle 客户端,并且必须是32 位(64 位不适用于 Visual Studio),那么我需要在应用程序池中允许 32 位
  5. 配置 Windows 防火墙以允许端口 80 中的请求(入站规则)

它正在工作!

I have some problems using IIS Express in Win 8.1 and external request.

I follow this steps to debug the external request:

  1. Install IIS
  2. Configure Visual Studio to use local IIS (Page properties in your Web Project)
  3. Create a exclusive AppPool in IIS to work with my application
  4. In my Project I'm using Oracle Client and must be 32bits (64 bits don't work with Visual Studio) then I need allow 32 bit in Application Pool
  5. Configure the Windows firewall to allow request in port 80 (inbound rules)

It's working!

¢蛋碎的人ぎ生 2024-09-17 16:53:21

如果您从管理员运行 Visual Studio,则只需添加

进入

%userprofile%\My Documents\IISExpress\config\applicationhost.config

If you run Visual Studio from Admin you can add just

<binding protocol="http" bindingInformation="*:8080:*" />

or

<binding protocol="https" bindingInformation="*:8443:*" />

into

%userprofile%\My Documents\IISExpress\config\applicationhost.config
把时间冻结 2024-09-17 16:53:21

我启用了本地 IIS,所以我刚刚为我的调试端口创建了一个重写规则...我认为这比其他方法更好、更酷,因为一旦完成开发就更容易删除...这是重写的外观。 VS

<rewrite>
    <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
            <match url="^dev/(.*)" />
            <action type="Rewrite" url="http://localhost:47039/{R:1}" />
        </rule>
    </rules>
</rewrite>

还允许您直接使用本地 IIS 进行开发(然后允许远程连接),但反过来您必须始终以管理员身份运行它......我不喜欢这样。

I had a local IIS enabled so i just created a rewrite rule to my debugging port... I think this is better and cooler than other method because it is easier to remove once am done developing... Here is how the rewrite looks..

<rewrite>
    <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
            <match url="^dev/(.*)" />
            <action type="Rewrite" url="http://localhost:47039/{R:1}" />
        </rule>
    </rules>
</rewrite>

VS also allows you to develop using your local IIS directly (which then allows remote connections) but in turn you must always run it as an administrator... I dont like that.

耶耶耶 2024-09-17 16:53:21

访问外部请求的另一种方法是使用 IIS 而不是 IIS Express。
在我的视觉工作室中,我可以轻松切换。

输入图片此处描述

Another way to access external requests is to use IIS instead of IIS Express.
In my visual studio, I can just switch easily.

enter image description here

从来不烧饼 2024-09-17 16:53:21

我通过使用反向代理方法解决了这个问题。

我安装了 wamp 服务器并使用了 apache Web 服务器的简单反向代理功能。

我添加了一个新端口来监听 Apache Web 服务器 (8081)。然后我添加代理配置作为该端口的虚拟主机。

<VirtualHost *:8081>
ProxyPass / http://localhost:46935/
ProxyPassReverse / http://localhost:46935/
</VirtualHost>

I solved this problem by using reverse proxy approach.

I installed wamp server and used simple reverse proxy feature of apache web server.

I added a new port to listen to Apache web server (8081). Then I added proxy configuration as virtualhost for that port.

<VirtualHost *:8081>
ProxyPass / http://localhost:46935/
ProxyPassReverse / http://localhost:46935/
</VirtualHost>
趁年轻赶紧闹 2024-09-17 16:53:21

我执行了所有这些步骤,但没有任何帮助。
我需要的只是通过 IIS Express 运行我的应用程序...

在此处输入图像描述

希望有帮助。

I did all of these steps and nothing helped me.
And what I need, it's just to run my app via IIS Express...

enter image description here

Hope it helps.

乱了心跳 2024-09-17 16:53:21

对于我来说,使用它相对简单且直接:

通过在扩展对话框中搜索“Conveyor”来下载 Visual Studio 扩展。然后只需安装即可。

形式:
https://marketplace.visualstudio.com/items?itemName=vs- publisher-1448185.ConveyorbyKeyoti

For me using this, relatively simple, and straight forward:

Download the Visual Studio Extension by searching for 'Conveyor' in the Extensions dialog. Then just install.

form:
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

疏忽 2024-09-17 16:53:21

我无法向本地网络中的其他用户提供 iis 请求,我所要做的就是(除了上述之外)重新启动我的 BT Hub 路由器。

I was unable to serve iis requests to other users in my local network, all I had to do (in addition to the above) was restart my BT Hub router.

汐鸠 2024-09-17 16:53:21

这太棒了,甚至用漂亮的域名覆盖了 HTTPS:

http://www.hanselman.com/ blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

我在其他任何地方都找不到真正很棒的部分,以防万一上述链接消失:

> C:\Program Files (x86)\IIS Express>IisExpressAdminCmd.exe Usage:
> iisexpressadmincmd.exe <command> <parameters> Supported commands:
>       setupFriendlyHostnameUrl -url:<url>
>       deleteFriendlyHostnameUrl -url:<url>
>       setupUrl -url:<url>
>       deleteUrl -url:<url>
>       setupSslUrl -url:<url> -CertHash:<value>
>       setupSslUrl -url:<url> -UseSelfSigned
>       deleteSslUrl -url:<url>
> 
> Examples: 1) Configure "http.sys" and "hosts" file for friendly
> hostname "contoso": iisexpressadmincmd setupFriendlyHostnameUrl
> -url:http://contoso:80/ 2) Remove "http.sys" configuration and "hosts" file entry for the friendly  hostname "contoso": iisexpressadmincmd
> deleteFriendlyHostnameUrl -url:http://contoso:80/

上述实用程序将为您注册 SSL 证书!如果您使用 -UseSelfSigned 选项,则非常简单。

如果您想以困难的方式做事,不明显的部分是您需要告诉 HTTP.SYS 使用什么证书,如下所示:

netsh http add sslcert ipport=0.0.0.0:443 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=YOURCERTHASHHERE

Certhash 是您可以从 MMC 中的证书属性获取的“指纹”。

This is insanely awesome and even covers HTTPS with pretty domain names:

http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

The really awesome parts I couldn't find anywhere else on SO in case the above link ever goes away:

> C:\Program Files (x86)\IIS Express>IisExpressAdminCmd.exe Usage:
> iisexpressadmincmd.exe <command> <parameters> Supported commands:
>       setupFriendlyHostnameUrl -url:<url>
>       deleteFriendlyHostnameUrl -url:<url>
>       setupUrl -url:<url>
>       deleteUrl -url:<url>
>       setupSslUrl -url:<url> -CertHash:<value>
>       setupSslUrl -url:<url> -UseSelfSigned
>       deleteSslUrl -url:<url>
> 
> Examples: 1) Configure "http.sys" and "hosts" file for friendly
> hostname "contoso": iisexpressadmincmd setupFriendlyHostnameUrl
> -url:http://contoso:80/ 2) Remove "http.sys" configuration and "hosts" file entry for the friendly  hostname "contoso": iisexpressadmincmd
> deleteFriendlyHostnameUrl -url:http://contoso:80/

The above utility will register the SSL certificate for you! If you use the -UseSelfSigned option, it's super easy.

If you want to do things the hard way, the non-obvious part is you need to tell HTTP.SYS what certificate to use, like this:

netsh http add sslcert ipport=0.0.0.0:443 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=YOURCERTHASHHERE

Certhash is the "Thumbprint" you can get from the certificate properties in MMC.

单身狗的梦 2024-09-17 16:53:21

我执行了以下操作并能够连接:

1)将 IIS 快速配置绑定从本地主机更改为“*”

绑定协议=“http”绑定信息=“*:8888:*”

2)在防火墙上定义的入站规则以允许特定的入站规则协议类型的端口:tcp

3) 添加以下命令为您的端口添加网络配置:
netsh http 添加 urlacl url=http://*:8888/ user=everyone

I did the following and was able to connect:

1) changed IIS express config binding from local host to '*'

binding protocol="http" bindingInformation="*:8888:*"

2) Defined inbound rule on firewall to allow the particular port for the protocol type: tcp

3) Add the following command to add network configuration for your port:
netsh http add urlacl url=http://*:8888/ user=everyone

万劫不复 2024-09-17 16:53:21

在我的 dotnet core 6 项目中帮助我允许远程访问我的 IIS 服务器的是在 [解决方案目录]/Properties/launchSettings.json 中设置项目的“applicationUrl”参数,将值从“http://localhost:5000”更改为” 到“http://0.0.0.0:5000”

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:20845",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MyLittleProject": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "applicationUrl": "http://0.0.0.0:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

但正确设置防火墙以允许访问服务器的 TCP 端口也很重要:在我的例子中,添加了 TCP 端口 5000 的入站规则以允许连接。

What helped me in my dotnet core 6 project to allow remote access to my IIS server is to set up the project's "applicationUrl" parameter in [solution directory]/Properties/launchSettings.json changing the value from "http://localhost:5000" to "http://0.0.0.0:5000"

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:20845",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MyLittleProject": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "applicationUrl": "http://0.0.0.0:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

But it's also important to set up a firewall properly to allow access to server's TCP port: in my case an inbound rule for TCP port 5000 to allow connections was added.

染墨丶若流云 2024-09-17 16:53:21

我使用 nginx 进行以下配置,它可以工作。

    location / {
        proxy_pass  http://localhost:<your port>/;
        expires -1;
    }

我被告知 ngrok 也可以工作,但由于木马,它在下载后继续被 Microsoft Defender 删除。

I used nginx with the following configuration and it works

    location / {
        proxy_pass  http://localhost:<your port>/;
        expires -1;
    }

I was informed that ngrok works as well, but it kept on deleted by Microsoft Defender after download, because of Trojan.

苹果你个爱泡泡 2024-09-17 16:53:21

[项目属性对话框]

对于使用 VisualStudio 2017 和 NetCore API 项目进行开发:

1) 在 Cmd-Box 中: ipconfig /all 以确定 IP 地址

2a) 在项目属性 -> 输入检索到的 IP 地址调试选项卡

2b) 选择一个端口并将其附加到步骤 2a 中的 IP 地址。

3) 在防火墙中添加允许规则以允许所选端口上的传入 TCP 流量
(我的防火墙触发了一个对话框:“阻止或添加规则到防火墙”)。在这种情况下,添加 will 就可以解决问题。

上述解决方案的缺点:

1) 如果您使用动态 IP 地址,则需要重做上述步骤,以防分配了另一个 IP 地址。

2) 您的服务器现在有一个开放端口,您可能会忘记,但这个开放端口仍然是对不速之客的邀请。

[project properties dialog]

For development using VisualStudio 2017 and a NetCore API-project:

1) In Cmd-Box: ipconfig /all to determine IP-address

2a) Enter the retrieved IP-address in Project properties-> Debug Tab

2b) Select a Port and attach that to the IP-address from step 2a.

3) Add an allow rule in the firewall to allow incoming TCP-traffic on the selected Port
(my firewall triggered with a dialog: "Block or add rule to firewall"). Add will in that case do the trick.

Disadvantage of the solution above:

1) If you use a dynamic IP-address you need to redo the steps above in case another IP-address has been assigned.

2) You server has now an open Port which you might forget, but this open port remains an invitation for unwanted guests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文