Configuring NodeJS

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 “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, answer) {
response.writeHead(200, {'Content-Type':'text/html' }) ;
response.end('H1>Hello World!</H1>') ;
).listen(process.env.PORT) ;)

console.log('The application is running') ;

[//code]

 

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)"""&gt ;
Welcoming order, refusing
deny everyone
"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