• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Resolved use nodejs and problem with express routing

rmazarlou

New Pleskian
I upload and extract this GitHub - plesk/node-express: A simple Express-based app to test Node.js support. project on /httpdocs folder and change Application

Startup File to server.js and after browsing the domain like this : http://www.mydomain.com and see

Express welcome message

but when I want get users with this url http://www.mydomain.com/users server give me this error :

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

 
I solve it :)

just add rewrite rule and handlers in web.config like this :


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

<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>

</rules>

</rewrite>

<directoryBrowse enabled="true" />

<iisnode devErrorsEnabled="true" debuggingEnabled="true" loggingEnabled="false" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
 
I solve it :)

just add rewrite rule and handlers in web.config like this :


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

<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>

</rules>

</rewrite>

<directoryBrowse enabled="true" />

<iisnode devErrorsEnabled="true" debuggingEnabled="true" loggingEnabled="false" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
Dear rmazarlou, I'd like to thank you for this post. Spent days dealing with nodejs on windows plesk in vain. Thanks to this article, i made it wonderfully, thanks again.
 
Hey People,
i found this question here and tried the solution but i still have some problems after that change.
The url: test.mydomain.com gives me a repsone that my express server is started
i also get a response if i try the url "test.mydomain.com/api/hello"
but when i try to call "test.mydomain.com/api/auth/user/login" it is giving only a 404 back from plesk.

My rewrite rules:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <httpErrors>
      <remove statusCode="400" />
      <error statusCode="400" path="C:\Inetpub\vhosts\mydomain.com\error_docs\bad_request.html" />
      <remove statusCode="401" />
      <error statusCode="401" path="C:\Inetpub\vhosts\mydomain.com\error_docs\unauthorized.html" />
      <remove statusCode="403" />
      <error statusCode="403" path="C:\Inetpub\vhosts\mydomain.com\error_docs\forbidden.html" />
      <remove statusCode="404" />
      <error statusCode="404" path="C:\Inetpub\vhosts\mydomain.com\error_docs\not_found.html" />
      <remove statusCode="405" />
      <error statusCode="405" path="C:\Inetpub\vhosts\mydomain.com\error_docs\method_not_allowed.html" />
      <remove statusCode="406" />
      <error statusCode="406" path="C:\Inetpub\vhosts\mydomain.com\error_docs\not_acceptable.html" />
      <remove statusCode="407" />
      <error statusCode="407" path="C:\Inetpub\vhosts\mydomain.com\error_docs\proxy_authentication_required.html" />
      <remove statusCode="412" />
      <error statusCode="412" path="C:\Inetpub\vhosts\mydomain.com\error_docs\precondition_failed.html" />
      <remove statusCode="414" />
      <error statusCode="414" path="C:\Inetpub\vhosts\mydomain.com\error_docs\request-uri_too_long.html" />
      <remove statusCode="415" />
      <error statusCode="415" path="C:\Inetpub\vhosts\mydomain.com\error_docs\unsupported_media_type.html" />
      <remove statusCode="500" />
      <error statusCode="500" path="C:\Inetpub\vhosts\mydomain.com\error_docs\internal_server_error.html" />
      <remove statusCode="501" />
      <error statusCode="501" path="C:\Inetpub\vhosts\mydomain.com\error_docs\not_implemented.html" />
      <remove statusCode="502" />
      <error statusCode="502" path="C:\Inetpub\vhosts\mydomain.com\error_docs\bad_gateway.html" />
      <remove statusCode="503" />
      <error statusCode="503" path="C:\Inetpub\vhosts\mydomain.com\error_docs\maintenance.html" />
    </httpErrors>
    <tracing>
      <traceFailedRequests>
        <clear />
      </traceFailedRequests>
    </tracing>
    <handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
</handlers>


<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="index.js" />
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^index.js\/debug[\/]?" />
</rule>


</rules>


</rewrite>


<directoryBrowse enabled="true" />


<iisnode devErrorsEnabled="true" debuggingEnabled="true" loggingEnabled="false" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
  </system.webServer>
  <system.web>
    <compilation tempDirectory="C:\Inetpub\vhosts\mydomain.com\tmp" />
  </system.web>
</configuration>
 
Back
Top