0

I am trying to load a NodeJS App from Apache+Passenger.

OS: Centos 7 / CloudLinux release 7.9

Apache: 2.4.6 ( httpd-2.4.6-97.el7_9.cloudlinux.x86_64 )

Passenger: Phusion Passenger 6.0.7 ( passenger-6.0.7-1.el7.x86_64, mod_passenger-6.0.7-1.el7.x86_64 ) from Passenger's Yum repo

The virtual host points to /home/vhost1/public_html and the NodeJS App points to /home/vhost1/nodeapps/np1-pass/np1-pass.js

When I run this config via Passenger entries in Apache's config, the application works and is accessible from http://virtual-host/np1-pass/ .

The entry in Apache's config is as under :

<VirtualHost *:80>
   ServerName virtual-host
   DocumentRoot /home/vhost1/public_html

   <Directory /home/vhost1>
      # Relax Apache security settings
      AllowOverride all
      Require all granted
      # MultiViews must be turned off
      Options -MultiViews
   </Directory>

   <Directory /home/vhost1/public_html>
      # Relax Apache security settings
      AllowOverride all
      Require all granted
      # MultiViews must be turned off
      Options -MultiViews
   </Directory>

  Alias /np1-pass /home/vhost1/nodeapps/np1-pass/public
  <Location /np1-pass>
     PassengerAppEnv development
     Passengerapproot /home/vhost1/nodeapps/np1-pass
     PassengerBaseURI "/np1-pass"
     PassengerNodejs "/home/vhost1/bin/node"
     PassengerAppType node
     PassengerStartupFile np1-pass.js
  </Location>

</VirtualHost>

What now I have been trying was to move over Passenger directives to the .htaccess file under /home/vhost1/public_html/np1-pass (of-course after removing those directives and the alias and location entry from the Apache config) so that a virtual host owner is able to fire the application without modifying Apache's config, then I get the error

PassengerAppRoot not allowed here, referer: http://virtual-host/np1-pass/

A similar .htaccess works fine for CloudLinux 7 on a cPanel server with Passenger ea-apache24-mod-alt-passenger-5.3.7-9.el7.cloudlinux.x86_64 package installed

When I was looking into various solutions, I came across two documents

  1. https://www.phusionpassenger.com/docs/references/config_reference/apache/#passengerapproot
  2. https://www.phusionpassenger.com/library/config/apache/reference/#passengerapproot

W.r.t. Passenger directives in the 1st link document, under the directive's context .htaccess is missing . But same is present in the 2nd link document

Now I have 2 questions

  1. Are both documents correct or am I missing something. ?
  2. And why the same setup is working fine on CloudLinux 7 on a cPanel server with Passenger ea-apache24-mod-alt-passenger-5.3.7-9.el7.cloudlinux.x86_64 package installed ?

Thanks

Kirti Singh

1 Answers1

0

W.r.t. the question

Are both documents correct or am I missing something. ?

I can't say about that, but I found this useful link https://blog.phusion.nl/2018/01/29/passenger-5-2-0/ which states that many Passenger .htaccess directives have been disabled since Passenger 5.2.0 . But still as both links mentioned in the original question do exist, those links should have had a version prefixed or there should have been a clarification in their content.

Now w.r.t. the 2nd question

And why the same setup is working fine on CloudLinux 7 on a cPanel server with Passenger ea-apache24-mod-alt-passenger-5.3.7-9.el7.cloudlinux.x86_64 package installed ?

I can't say how CloudLinux is doing it, but I was able to run passenger directives via .htaccess by uninstalling the passenger 6.0.7 and the corresponding mod_passenger , and then by installing the old passenger version 5.1 and its corresponding mod_passenger

`yum remove passenger
 yum install passenger-5.1.12-1.el7
 yum install mod_passenger-5.1.12-1.el7`

This solved my problem and now I am able to load NodeJS apps via .htaccess

I hope my answer helps others who struggle with this issue.