Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iis7 returns 404 not found error randomly for node.js sites

Server, located in Germany
Windows Server 2008 / IIS 7
node.js 0.8.22
iisnode 0.2.2 x64

web.config

<configuration>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
    </handlers>

    <rewrite>
      <rules>
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
          </conditions>
          <action type="Rewrite" url="server.js"/>
        </rule>
      </rules>
    </rewrite>

    <iisnode watchedFiles="*.js;lib\*;node_modules\*;styles\*;ui\*;views\*" />

  </system.webServer>
</configuration>

server.js

var port = process.env.NODE_ENV == 'production' ? process.env.PORT : 3000;

require('./lib/server').listen(port);

Site Link

Problem:
Sometimes I get 200 response, but sometimes 404 (File or directory not found).

If I do request from Russia, Germany or USA, response is 200.
If I do request from China, sometimes response is 404 (Depends on ISP, time and maybe something else).

404 response looks like iis can not find server.js

Example of 200 response (Using express Vpn, connected to USA):

2013-04-29 02:42:58 W3SVC1 LOFT4002 188.138.16.31 GET /zazaza - 80 - 180.150.157.51 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.2;+WOW64)+AppleWebKit/537.31+(KHTML,+like+Gecko)+Chrome/26.0.1410.64+Safari/537.31 connect.sid=s%3ABHin0EtiPcJbD6GCeXE2hb_1.mNHhYwIs%2BvLKcJcXc1igMH4O%2FIkuwQdygd1XjN7ediM - test.amelisa.ru 200 0 0 367 530 514

Example of 404 error (Without vpn, request from China):

2013-04-29 02:32:47 W3SVC1 LOFT4002 188.138.16.31 GET /zazaza - 80 - 112.90.90.18 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.2;+WOW64)+AppleWebKit/537.31+(KHTML,+like+Gecko)+Chrome/26.0.1410.64+Safari/537.31 connect.sid=s%3AdL_RALh0qLd0eLoCxZUk6Po-.N9h97BMFy9%2Fm9tl8lrQd%2FIHQjwpwzEXfWC7f4%2FrHxpY - test.amelisa.ru 404 0 0 1390 532 436

iisnode have no logs neither traces for 404 requests, so I think it`s not even starts for them.

The same issue with all iisnode/node.js sites on this server.
But Asp Net Mvc web site on this server return 200 any case, so it may be not Chinese Golden Shield issue.

I can provide any information.
Any help will be appreciated.

like image 700
Vladimir Makhaev Avatar asked Apr 29 '13 04:04

Vladimir Makhaev


1 Answers

try to create a route to your solution to test like:

//my route to test "GET", make sure if your route is "POST"
app.get('/test', function(req, res){
     res.json(true);
});

Now use the url to test: http://test.amelisa.ru/test

This error happen when there is not route to that path. I was with the same problem and it resolved.

I hope it helps. If not, please, share your code in './lib/server' to help more.

like image 195
Lucas Argate Avatar answered Nov 06 '22 18:11

Lucas Argate