Configuring NodeJS

Support Wissensdatenbank

Du bist hier:
Print

To use Node.js on one of our hosting packages, please proceed as follows:

  1. Log in to Plesk (access to Plesk).
  2. Click on the “Node.js” button
  3. Define a document master record and an application launch file.
  4. After you have configured all the settings correctly, you can start the application. If the settings are incorrect, you will see a red exclamation mark.

    You can download the following test script as app.js to test Node.js:

const http = require("http");

http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
response.end("<H1>Hello World!</H1>");
}).listen(process.env.PORT);

console.log("App is running");

  As you can see, the page https://musterdomain.ch/app shows the expected number (“Hello World!”). If you now open the file, you will find the source code of Node.js (https://musterdomain.ch/app.js). This is because NGINX and Node.js work in parallel on your hosting. To prevent the source code from reading your Node.js application, place the”.htaccess” file at the root of your application document and enter the following content:

<Files ~ "(.js|.css)">
Order allow,deny
deny from all
</Files>

 

War dieser Artikel hilfreich?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
Wie können wir diesen Artikel verbessern?
Please submit the reason for your vote so that we can improve the article.
Brauchst du Hilfe?
Related Post