apache + redmine 403 - premissions are good - apache

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.

Related

Passenger directives not working in Apache 2.4 .htaccess

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.

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.

Clean URLs Test Fails with Drupal 7 on EC2 Ubuntu 12.04 Instance

I've already enabled mod-rewrite with
sudo a2enmod rewrite
I've added my Drupal7 install to the apache config file located in /etc/apache2/sites-available/default (note: Is this the correct config file to edit?)
<Directory "/var/www/myDrupal">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Then I restarted Apache2 with
sudo /etc/init.d/apache2 restart
Yet it still fails the Clean URL test in Drupal. I've been banging my head against the keyboard for far too long. Anyone have any other suggestions?
If you have it residing in a "myDrupal" folder off the root, then it is in a sub directory. You need to edit .htaccess, and uncomment "RewriteBase /" on line 110.
Just change
# RewriteBase /
to
RewriteBase
Then Flush your Drupal Cache and try again.
If your .htaccess looks good, and the apache config file is set correctly with AllowOverride All, try navigating to clean-urls configuration page by yourSite.com/admin/config/search/clean-urls and enable it! Clean URL's test sometimes fails even though your server is properly configured to rewrite.
Good luck!
You need to enable mod_rewrite. You'll have to cause the following to happen during instance createion:
a2enmod rewrite
service apache2 restart
Enabling clean urls for Ubuntu 14.04
(1) Run the command a2enmod rewrite on your ubuntu (Command Line Interface) CLI to make sure rewrites are installed.
(2) vi /etc/apache2/apache2.conf
a. Under all the AllowOverride All
(3) In the .htaccess file under /var/www/ if that is your place of drupal installation make sure the Rewritebase / is uncommented and correct. If your drupal installation is **Rewritebase /var/www/drupa**l, then change it to that.
(4) Run command service apache2 restart on your ubuntu CLI and you should be good.
* Optional - make sure your root
~Good Luck

Mod_rewrite not working on Ubuntu Server (works locally, though)

I have a local environment working fine. Pasted a test route in .htaccess and it works as expected (re-routes me to google).
RewriteEngine on
RewriteRule testpage\.html http://www.google.com [R]
I pasted the same thing on my development server (Unbutu 12.04) and it simply gives me a Not Found page. When I verify it on the devserver by running:
sudo a2enmod rewrite
It says "Module rewrite already enabled".
Edit: It also appears in the "loaded modules" section of phpinfo() and I have restarted the apache server several times since it was installed.
Any ideas?
Most likely it is because mod_rewrite is enabled but .htaccess files are disabled via
AllowOverride None
which disables checking .htaccess files (which gives You some performance gains but You have to put Your mod_rewrite code directly in apache configuration files)
Change for Your virtual host to:
AllowOverride All
For people who don't understand - http://victorpotapov.ru/blog/vkljuchaem_mod_rewrite_v_apache/2013-11-03-61
On this page you can see step by step, that you enter in your terminal on ubuntu
enable mod_rewrite
Activate the mod_rewrite module with
sudo a2enmod rewrite
and restart apache
sudo service apache2 restart
Edit virtual host to use mod rewrite within .htaccess
sudo nano /etc/apache2/sites-available/000-default.conf
Search for "DocumentRoot /var/www/html" and add the following lines
<Directory "/var/www/html">
AllowOverride All
</Directory>
Save & Exit CTRL-X, "Y" and Enter
Restart Apache
sudo service apache2 restart

Passenger just showing directory in Apache

I am trying to use Passenger to deploy a rails app on Ubuntu with Apache. I've followed pretty much every guide I could find on configuring Passenger with Apache/Ubuntu. However, when I go to the site, I just see the actual file directories and not the running version of the application. If i switch to the /public directory I just see the public directory when I go to the site. I can start and stop the rails server by calling rails s without getting any errors, but still am not able to see the running version of the application. Does anyone ran into similar problems? Is there a good starting point anyone could suggest I look at? I'm not sure if the problem is with apache or passenger.
Apache config
LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRuby /usr/bin/ruby
PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
PassengerMaxPoolSize 10
<VirtualHost *:80>
ServerName http://www.myapp.com/
DocumentRoot /var/www/myapp/current/
<Directory /var/www/myapp/current/public>
Allow from all
</Directory>
When I restart apache, I get a message stating [Sun Nov 06 14:43:48 2011] [warn] module passenger_module is already loaded, skipping I'm not sure if this is an error or is normal.
Update
When I run find / -name 'mod_passenger.so' I get two locations:
/usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
/usr/lib/apache2/modules/mod_passenger.so
Update 2
I have several passenger.config files
/etc/apache2/mods-enabled/passenger.conf
/etc/apache2/mods-available/passenger.conf
/usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/debian/passenger.conf
Each of the passenger.conf files has the following:
<IfModule mod_passenger.c>
PassengerRoot /usr
PassengerRuby /usr/bin/ruby
</IfModule>
Try to put following in apache config file
<Directory /var/www/myapp/current/public>
Allow from all
#Add following line
Options +Includes -Indexes
</Directory>
You may have mod_passenger.so symlinked into your apache2/mods-enabled directory. This would account for the double import.
Run
a2dismod mod_passenger.so
to remove any symlink, then restart Apache.