2

I want to run a Node.js Express app together with Apache configured by CPanel

Instructions for "CPanel How to Install a Node.js Application" describe setting up an Express app listening on port 3000. https://documentation.cpanel.net/display/CKB/How+to+Install+a+Node.js+Application. But CPanel >> Home >> Software >> Application Manager has no input to enter the port where requests should be forwarded.

The running Express app responds to curl http://127.0.0.1:3000

Expected a request to url http://example.com/nodejsapp to receive a response from the Node.js App but get a 404 Error instead. Should forwarding to a particular port be included ?

0

1 Answer 1

5

You mush config .htaccess :

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]

with XXXXX is your port .

Sign up to request clarification or add additional context in comments.

5 Comments

The express app is listening on 3000 should both sets of XXXX be 3000 ? Where is that port number set up in the CPanel Application Manager ?
No, you must config in .htaccess and you can set port server at server.js (file contain your server code) . Then you want run at port 3000 , you must set XXXXX to 3000
Implemented that but still getting a 404
I beleive you must contact your hosting provider. Because It is including server config . Tell me problem after contact your hosting provider .
This worked like a charm for me. Running React/Next SSR application on Fast Comet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.