IISを使用して実行したいNode Applicationがあります。問題は私の設定ファイルです。私はIIS 10.0を使用しており、すべてを正しく設定する方法を知らないのですか?私は...私のWeb.ConfigファイルにIISノードアプリケーションはWeb.Configで正しく動作しませんか?
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent" patternSyntax="Wildcard">
<action type="Rewrite" url="public/{R:0}" logRewrittenUrl="true"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
</conditions>
<match url="*.*"/>
</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>
をこれらのルールの両方が含まれるたびに...私はこのようになります500.1000エラーを取得:私は1つを取るとき
をかもう一方は、私のウェブサイトのページとリンクが正しくロードされますが、すべてのPOST要求は404エラーを作成しますか?これは、server.jsファイルでPOST関数を呼び出す代わりに、物理パスを検索しているためです。ここで
は404 ERRORです:
それは(& POSTリクエストをGET)動作するため、私は、自分のサイトが機能することを知っているここでVS 2015のためのデバッガである私のコードから抜粋し、構成ファイル。ここで
はフルWeb.Configファイルである:助けを
var http = require('http');
var express = require('express');
var fs = require("fs");
var sql = require("mssql");
var bodyParser = require('body-parser'); // Used to parse incoming messages
var Connection = require('tedious').Connection; // Added for Azure
var app = express();
var port = process.env.port || 1337;
// pulls the index.html file
app.use(express.static(__dirname + "/"));
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
// DATABASE configuration
var config = {
userName: 'USERNAME',
password: 'PASSWORD',
server: 'SERVER',
options: {
encrypt: true,
database: 'DATABASE',
rowCollectionOnRequestCompletion: true
}
};
var connection = new Connection(config);
// Server that listens to port 80
var server = http.createServer();
var server = app.listen(port, function() {
var host = server.address().address
var port = server.address().port
console.log("Node Js app listening at http://%s:%s", host, port)
});
app.post('/postrequest', function (req, res) {
// function
});
ありがとう:ここ
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!--
All appSettings are made available to your Node.js app via environment variables
You can access them in your app through the process.env object.
process.env.<key>
-->
<!-- Unconmment the below appSetting if you'd like to use a Virtual Directory -->
<!-- <add key="virtualDirPath" value="" /> -->
</appSettings>
<system.webServer>
<iisnode node_env="%node_env%"
nodeProcessCountPerApplication="1"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="100"
namedPipeConnectionRetryDelay="250"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
uncFileChangesPollingInterval="5000"
gracefulShutdownTimeout="60000"
loggingEnabled="true"
logDirectory="iisnode"
debuggingEnabled="true"
debugHeaderEnabled="false"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
maxTotalLogFileSizeInKB="1024"
maxLogFiles="20"
devErrorsEnabled="true"
flushResponse="false"
enableXFF="false"
promoteServerVars=""
configOverrides="iisnode.yml"
watchedFiles="web.config;*.js"
nodeProcessCommandLine="C:\Program Files\nodejs\node.exe"/>
<!--
Before the handlers element can work on IIS 8.5
follow steps listed here https://github.com/tjanczuk/iisnode/issues/52
-->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
<!-- Uncomment below handler if using Socket.io -->
<!--<add name="iisnode-socketio" 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" patternSyntax="Wildcard">
<action type="Rewrite" url="public/{R:0}" logRewrittenUrl="true"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
</conditions>
<match url="*.*"/>
</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>
<rule name="SocketIO" patternSyntax="ECMAScript">
<match url="socket.io.+"/>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false"/>
</system.webServer>
</configuration>
私server.jsファイルの一般的な構造です。私はこの問題を理解していないようです。
私はスクリプトと呼ばれるこのディレクトリ内の別のフォルダにある別のスクリプトでポストを要求します
xhttp.open("POST", "http://localhost:80/My Application/postrequest", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("date=" + date + "&name=" + name + "&type=" + type);