将来自Azure Web应用程序的HTTP请求发送到我的机器 [英] sending http request from azure web app to my machine
问题描述
我创建了一个发送http请求的azure网络应用程序:
I created an azure web app which send an http request:
axios.post('http://*mypublicip*:3000/write/' + Name, {
content: data[1]
})
同时我的计算机上有一个正在运行的Express服务器:
meanwhile my computer has a running express server:
app.listen(3000, () => console.log(`Server running on port ${port}`));
当我在本地使用它时,通过将请求发送到localhost而不是我的ip,我的所有功能都起作用.我还尝试将主机"0.0.0.0"添加到我的app.listen中.我想念什么?谢谢
all my functionality works when I use it locally by sending the request to localhost instead of my ip. I also tried adding host '0.0.0.0' to my app.listen. what am I missing? thanks
推荐答案
此问题与您的网络应用无关.
因此,我将不再测试该Webapp程序,您可以通过其他机器(而不是其他)访问 http://* mypublicip *:3000/write/'+名称
的http请求LAN中的PC),我的测试环境是azure内置的vm.您会发现无法成功访问您的请求.
So I will not test the webapp program anymore, you can access your http request of http://*mypublicip*:3000/write/' + Name
through other machines (not PCs in the LAN) , My test environment is vm built in azure. You will find that your request cannot be accessed successfully.
原因是您在 cmd
的 ipconfig
中找到的 ip
不应是您的主机 ip
,但是运营商分配给您的互联网IP.许多主机都使用此 ip
.简而言之,这个 ip
不仅是您的机器之一.
The reason is that the ip
you found in ipconfig
in cmd
should not be your host ip
, but the Internet ip assigned to you by the operator. This ip
is used by many hosts. Simply put, this ip
is not just one of yours Machines.
因此导致您的问题发生.建议使用Intranet渗透工具来实现此目的.这意味着使用Intranet渗透工具公开您的3000端口.
So cause your problem to happen. It is recommended to use intranet penetration tools to achieve this. It means to use the intranet penetration tool to expose your 3000 port.
为解决您的问题,我使用了 ngrok
.
To solve your problem, I used ngrok
.
- 在本地构建项目并监视端口
3000
.
- 本地访问,检查效果.
- 在虚拟机中访问,发现失败.
- 安装ngrok之后,虚拟机将访问新地址并成功.
首先允许暴露端口3000.
在vm中测试,它可以正常工作.
Test in vm, it works.
这篇关于将来自Azure Web应用程序的HTTP请求发送到我的机器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!