
[英]Daemon OWASP ZAP on Azure App Service always returns code 400 - Bad Request
[英]Nodejs app in Azure app service always returns HTTP ERROR 404
我正在尝试学习部署一个非常基本的 nodejs“hello world”应用程序的 azure 应用程序服务。 我从 Azure Devops 服务器发布管道成功部署了该应用程序,我可以在 azure 门户中看到该应用程序已启动 state 但是当我尝试访问它时我得到
找不到此 sieracnodejasdemo.azurewebsites.net 页面 HTTP 错误 404。而应用程序已启动并正在运行
这是基本的 index.js
var http = require('http');
var server = http.createServer(function(request, res) {
res.writeHead(200, { "Content-Type": "text/plain" });
var url = request.url;
if (url === '/about') {
res.write(' Welcome to about us page');
res.end();
} else if (url === '/contact') {
res.write(' Welcome to contact us page');
res.end();
} else {
res.write('Hello World!');
res.end();
}
});
const port = process.env.PORT || 3000;
console.log(port);
server.listen(port);
console.log("Server running at http://%d", port);
在我看来这是端口的问题,所以第一个问题我应该为端口添加防火墙规则吗? 我什至用 80 替换了 process.env.PORT 但 id 没有帮助,总是同样的错误。 我试图在设置中将节点版本更改为 ~10 或 18,但都没有帮助。 那么我缺少什么才能使其正确响应? 知道当我在本地机器上运行它时它工作正常谢谢你的帮助
我尝试在我的环境中重现相同的内容,并且能够在执行以下步骤后成功部署 nodeJS 应用程序。
第 1 步:在 VS 代码中创建一个示例 nodeJS 应用程序并将其推送到 Azure Repos。
第 2 步:创建构建步骤如下。
第 3 步:运行管道并验证生成的工件。
第 4 步:使用运行时“ Node 18 LTS”和操作系统Linux创建一个 Azure 应用服务
Step5:在Azure DevOps中创建Service连接
第 6 步:创建一个发布管道,如下所示。
第 7 步:部署完成后,验证应用服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.