/ / aplicativo da web do nó no azure está em branco - node.js, azure, express, deployment

aplicativo da web do nó no azure está em branco - node.js, azure, express, deployment

Eu sou novo no nó e expressar, mas eu estou tendo um problema quando eu hospedar meu nó web app no ​​windows azure que por sinal funciona completamente bem em localhost. Acabei de receber uma tela branca em branco.

este é meu: server.js

var root = require("root");
var github = require("github-auth");
var express = require("express");
var path = require("path");

// var app = root();
var app = express();


var gh = github("clientid", "clientsecret, {
organization: "my-org",
team: "my-team",
autologin: true // This automatically redirects you to github to login
});


app.get("/login", gh.login);


app.use(express.static(__dirname + "/"));


app.all("*", gh.authenticate);
app.all("*", function(req, res, next) {
if (!req.github) return res.sendFile(__dirname + "/login.html");


if (!req.github.authenticated) res.sendFile(path.join(__dirname+"/kickout.html"));
next();
});

app.get("/main",function(req,res){
res.sendFile(path.join(__dirname+"/main.html"));
});

app.get("/about",function(req,res){
res.sendFile("/kickout.html");
});

app.listen(3000);

console.log("Running at Port 3000");

Respostas:

0 para resposta № 1

Ao hospedar aplicativos Node.js por meio do Azure Web Apps, você precisa modificar a inicialização da porta, conforme mostrado no exemplo simplificado a seguir:

var http = require("http"),
port = process.env.PORT || 1337;

http.createServer(function(req, res) {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Hello Worldn");
}).listen(port);

Quando executado localmente, a porta literal será usada (por ex. 1337 acima), mas ao executar no Azure, uma porta será atribuída a process.env.port pela plataforma de hospedagem e que será usada. Você pode encontrar um passo a passo completo na implantação de um aplicativo Node.js Aqui. Ao executar em um WebApp, uma tecnologia chamada Nó do IIS é usado para executar seu aplicativo do Node. Mais detalhes sobre isso podem ser encontrados Aqui.


1 para resposta № 2

O aplicativo Node.js em execução no Serviço do Azure Web Apps é hospedado no mapeamento manipulado do IIS por meio do IISNode, que fornece uma Named Pipe para receber as solicitações recebidas, não uma porta TCP como você usaria quando estiver executando localmente.

este Named Pipe foi definido como o port no tempo de execução Node.js no Azure Web Apps. Você pode definir o port no link do seu aplicativo: process.env.PORT || 3000, com o qual seu aplicativo pode ser executado no Azure ou localmente.

E você pode verificar se existe um arquivo web.config no seu diretório raiz, que são as configurações do IIS do seu aplicativo. Deve ter o conteúdo similar:

<configuration>
<system.webServer>
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>

<!-- Don"t interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js/debug[/]?" />
</rule>

<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>

<!-- All other URLs are mapped to the Node.js application entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
</rule>

</rules>
</rewrite>
<!-- You can control how Node is hosted within IIS using the following options -->
<!--<iisnode
node_env="%node_env%"
nodeProcessCommandLine="&quot;%programfiles%nodejsnode.exe&quot;"
nodeProcessCountPerApplication="1"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="3"
namedPipeConnectionRetryDelay="2000"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
watchedFiles="*.js"
uncFileChangesPollingInterval="5000"
gracefulShutdownTimeout="60000"
loggingEnabled="true"
logDirectoryNameSuffix="logs"
debuggingEnabled="true"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
appendToExistingLog="false"
logFileFlushInterval="5000"
devErrorsEnabled="true"
flushResponse="false"
enableXFF="false"
promoteServerVars=""
/>-->
<iisnode watchedFiles="*.js;node_modules*;routes*.js;views*.jade"/>
</system.webServer>
</configuration>