Passenger directives not working in Apache 2.4 .htaccess - apache

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
https://www.phusionpassenger.com/docs/references/config_reference/apache/#passengerapproot
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
Are both documents correct or am I missing something. ?
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

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.

Related

apache + redmine 403 - premissions are good

i searched sth about this a lot but solutions doesnt help so much.I tried to upgrade redmine to 2.6.5 on my FreeBSD but i have 403 error.
apache error log:
[autoindex:error] AH01276: Cannot serve directory
/usr/local/www/redmine/public/: No matching DirectoryIndex (none)
found, and server-generated directory index forbidden by Options
directive
my httpd conf:
<VirtualHost example.com:80>
DocumentRoot "/usr/local/www/redmine/public"
ServerName example.com
FastCgiServer /usr/local/www/redmine/public/dispatch.fcgi -idle-timeout 120 -initial-env RAILS_ENV=production -initial-env PATH=/usr/local/bin -processes 2
<Directory "/usr/local/www/redmine/public">
AddHandler fastcgi-script fcgi
Order allow,deny
Allow from all
AllowOverride all
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi
</Directory>
ErrorLog /logs/error.log
</Virtualhost>
i have to say: if i add +Indexes in Option i see files in my browser, so i guess premissions are good.
Anyone can give me any hint?
thanks in advance 4 your help
In my situation the problem was caused by a bug in the apache module ModAutoIndex. Disabling the module did the trick.
See https://serverfault.com/a/731859
Disabling the module auto index (which is the cause of the wrong behaviour, will prevent the error.
#LoadModule autoindex_module modules/mod_autoindex.so
Phusion will address the issue in the realase of Passenger 5.0.22 before Apache 2.5.0 will be released.
I suffered the same issue on my ArchLinux installation with Apache 2.4 and Redmine 2.6.5. Instead of fcgi I use the Phusion Passenger web application server but I always ended up on a 403 Forbidden page like you when accessing the server.
With the +Indexes option I also got the contents of the Redmine public directory on the browser.
When using webrick or passenger directly to host Redmine everything was fine. That's how you can verify your Redmine is not corrupted somehow. From the Redmine root directory run:
bundle exec ruby scripts/rails server -e production
Since I'm using RVM to manage ruby versions and gemsets on the system I can also tell you that the behavior is not related to ruby ( I tried every version from 1.8.x to 2.2.x without any change ).
In the end I substituted Apache with nginx 1.8.0 (stable release) and got Redmine back to work. So with passenger it's quite easy to get rolling. Just run
gem install passenger
so you get the passenger package. And then compile nginx with the passenger module using
passenger-install-nginx-module
You'll get an automated dialog that downloads nginx and compiles it with the appropriate config. By default it will be installed to /opt/nginx
On ArchLinux you would rather use the ABS to get the PKGBUILD and add the following to the configure part
--add-module=$(passenger-config --nginx-addon-dir) \
That way you also get the systemd unit-file to start and stop nginx.service
Last but not least here's the nginx config I use to run Redmine:
server {
listen 80;
server_name redmine.example;
root /usr/share/webapps/redmine-2.6.5/public;
passenger_base_uri /;
passenger_app_root /usr/share/webapps/redmine-2.6.5;
passenger_document_root /usr/share/webapps/redmine-2.6.5/public;
passenger_enabled on;
passenger_ruby /usr/local/rvm/gems/ruby-1.9.3-p551#redmine/wrappers/ruby;
}
Using another webserver may be a daunting step but it took me less than 2 hours to get Redmine up and running with nginx compared to nearly 2 days of wasted time to figure out why the heck Apache didn't serve the webapp any more.

redmine and mod_vhost_dbd

I've problem to run redmine with vhost_dbd_module from apache. Redmine was installed under /var/www/redmine/ directory. My apache config look:
<VirtualHost *:80>
ServerName HOSTNAME
DocumentRoot "/var/www/" # THIS IS NOT WORKING
# DocumentRoot "/var/www/redmine/public" # THIS WORKS WITH REDMINE
<Directory />
Options FollowSymLinks -MultiViews -Indexes
AllowOverride All
</Directory>
DBDriver mysql
DBDParams host=localhost,user=test,pass=test,dbname=test
DBDocRoot "SELECT document_root FROM vhosts WHERE server_name = %s" HOSTNAME
</VirtualHost>
Field document_root from database return '/var/www/redmain/public' - so it should works. It works for php projects where index file is under '/var/www/project/public'. Besides the page return 404 because in /var/www/redmain/public there is no index file. I want universal config
Any suggestions?
Best regards, Peter
Not havng a index.html is ok :) Check your config/routes.rb.
If rails service is running then your redmine rails check your routes.rb and deliver the default page there (view).
Passenger as an apache module is not compatible with about all modules used to define "dynamic" document roots (including mod_vhost_dbd). For passenger, you have to statically configure your apps in the Apache configuration.
Generally, you will have a hard time emulating your PHP setup with any Ruby app server, as they expect to be started once and run continuously, unlike PHP "apps" which act as scripts resolved and started new for each request. You should rethink your setup for persistent application server processes.
I created .htaccess with content below and it working :)
RailsBaseURI /
PassengerAppRoot /var/www/redmine

setting up passenger: keeps showing apache default page instead

I am trying to get passenger to work but i keep seeing the apache default page instead. I am using centos 6.3 on an inmotion VPS. Here is what I've done so far:
gem install passenger.
rvmsudo passenger-install-apache2-module
pasted the following code into /usr/local/apache/conf/includes/post_virtualhost_global.conf (this gets loaded into httpd.conf)
LoadModule passenger_module /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17
PassengerRuby /home/username/.rvm/wrappers/ruby-1.9.3-p194/ruby
<VirtualHost 123.123.123.123:80>
ServerName http://XXXXXX.inmotionhosting.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/username/rails/current/public
<Directory /home/username/rails/current/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
edit: not sure why this isnt formatting properly. its lined and tabbed fine in the text editor.
in etc/hosts there is the line:
123.123.123.123 XXXXXX.inmotionhosting.com XXXXXX
i restarted apache via sudo service httpd restart in /etc/init.d
still shows apache default page
Any ideas? thanks
I stumbled upon this 1 year old post for the similar problem but none of the comment worked for me. So I'm just adding my 2 cents for those who are looking for some help.
If you are seeing Apache default page, it means that phusion passenger is probably not running. You might have seen a warning message when you started/stopped/restarted the apache server that says the phusion passenger module is already loaded, skipping.
So Apache has skipped the most recent LoadModule line you added in the conf file.
Then check the error.log which is in the directory set for error log in apache config file. (httpd.conf for centos)
In my case, it was complaining that it couldn't find the watchdog in the directory set in PassengerRuby. This confirms that the passenger module loaded is NOT what I just added. This might have happened because I am using RVM now but also installed an old version of Passenger a while ago as a root. So I looked at the config.d directory under Apache root, there was a file "passenger.conf" that was loading the old version of Passenger.
I deleted the file, kept the new LoadModule as is - copied from the instruction Phusion Passenger gave me while installing apache2-module, restarted the apache server, no warning message, and passenger worked.

Website link shows Apache HTTP Server Documentation

My website directory /manual shows Apache HTTP Server Version 2.2 Documentation page i have removed this directory from my FTP but still o a, getting this.
I am using Linux Centos bellow is my manual.conf file configuration
There is a manual.conf which shows bellow configurations
#
# This configuration file allows the manual to be accessed at
# http://localhost/manual/
#
AliasMatch ^/manual(?:/(?:de|en|fr|ja|ko|ru))?(/.*)?$ "/var/www/manual$1"
<Directory "/var/www/manual">
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
You may need to remove that link from your server configuration. If you have done this you need also to restart your apache server.
To remove the documentation look into your apache configuration (on Debian e.g. /etc/apache2/sites-enabled/000-default) for a block like this one here:
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
...
</Directory>
And comment them with # out. Than don't forget to restart the apache server to commit the changes.
After your update you seems to have two options:
Delete the whole file. That should remove the link for ever.
Comment all that lines out by adding a # to the beginning of all lines. This is for some cases better if you want to recover the manual in the future.
And restart the server with:
service httpd graceful
In fedora
dnf remove httpd-manual.noarch
service httpd restart
If you still have this behaviour and want to correct it just disable the apache2-doc conf and restart the apache2 service. a2disconf apache2-doc.

Is it possible install Bugzilla into the apache server running collabnet subversion edge

I want to install bugzilla against the apache server that installed with collabnet edge. I've already gotten everything installed, my problem is that I can't figure out which httpd.conf file i need to edit. Collabnet Edge has about 5 conf files, all these files are autogenerated and warn "DO NOT EDIT" in the first line.
Does anyone know how I can do this? if not is it possible to install another [instance]? of apache?
ps: Also this is on windows 2008 server, with IIS shut off.
pps: Also, I am open to the idea of moving my repo to another svn server/issue tracker. as long as it's free and runs on server2008. I just have past experience with bugzilla (as a developer/enduser).
Any thoughts would be appreciated
Yes. It is. First, do not touch any files in the collabnet apache server install. I went ahead and installed a separate installed a separate instance of Apache, which I bound to an non-standard port. I had to add an alias line to the new apache to create Bugzilla as a folder under my main site
NameVirtualHost xxx.xxx.xxx.local
<VirtualHost
xxx.xxx.scgov.local>
ServerName xxx.xxx.xxx.local
DocumentRoot "C:/Apache2.2/htdocs"
</VirtualHost>
<VirtualHost
xxx.xxx.xxx.local>
ServerName xxx.xxx.xxx.local
DocumentRoot "C:/bugzilla"
</VirtualHost>
<Directory "C:\bugzilla">
AddHandler cgi-script .cgi
Options +Indexes +ExecCGI
DirectoryIndex index.cgi
AllowOverride Limit FileInfo Indexes
Order allow,deny
Allow from all
</Directory>
Once this was complete I was able to follow the tutorial at https://wiki.mozilla.org/Bugzilla:Win32Install
Also make sure you install ActivePerl # C:\usr if you don't you have to go in an change every *.cgi file.... read this tutorial on how to install ActivePerl to maximize portability with windows & linux http://www.ricocheting.com/how-to-install-on-windows/perl