How to run nodejs application in apache server

廉价感情. 提交于 2019-11-30 05:41:50

The configuration looks correct except for one bit, the /node location path should have the target matching slashes for reverse proxying correctly without unexpected consequences:

I'd rather define it like this for clarity's shake:

ProxyPass /node/ http://132.159.25.21:8080/
ProxyPassReverse /node/ http://132.159.25.21:8080/

Take into account while Proxying using the target http://132.159.25.21:8080 is incorrect, and it should always defined as http://132.159.25.21:8080/ and therefore the source should match slashes in the same fashion, therefore /node/ is the correct way.

As for "NameVirtualHost" warning. It's just telling you, that it is not needed any longer in 2.4.X version of Apache HTTPD since that directive is only needed for 2.2, 2.4 got "smarter" detecting named virtualhosts.

SideNote: <Proxy *> has no effect, so defining it is futile. Proxy * is used for forward proxying and clearly you do not want it and have disabled such functionality with ProxyRequests off. So remove that one also.

--- Answer extension due to your comments:

To reach your node you would have to access:

http://node.example.com/node/

or add a "default" redirection that takes you to it.Such as:

RedirectMatch ^/$ /node/

You are getting indexes (file list) by accessing node.example.com because -Indexes is defined for a subdirectory, meaning previous one has Indexes enabled, So define:

<Directory /home/abc/public_html>
    Options -Indexes +FollowSymLinks
    ....

Instead of defining /home/abc/public_html/node, which does not apply to this case, since node/ is not a directory, but a virtual path in a backend, so for correction shake it should never be included in a Directory path.

If you just want to access the backend while accessing http://node.example.com/ Just use this instead of ProxyPass /node/:

ProxyPass / http://132.159.25.21:8080/
ProxyPassReverse / http://132.159.25.21:8080/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!