NodeJS Setup

Support Wissensdatenbank

Du bist hier:

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 button “Node.js”
  3. Define a document master and an application start file.
  4. After you have configured all settings correctly, you can start the application. If the settings are wrong you will see a red exclamation mark.

 

 

You can upload 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'); 

[//code]

 

As you will notice, the page https://musterdomain.ch/app shows the expected issue ("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 run parallel on your hosting. To prevent the source code from reading your Node.js application, place the ".htaccess" file in the document root of your app and enter the following content:


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

[//code]
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?
Brauchst du Hilfe?
Related Post