Apache 2.4.7 403 Forbidden Error - apache

I'm trying to install the overpass api as a web server with apache (http://wiki.openstreetmap.org/wiki/Overpass_API/install)
Here is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html
# This directive indicates that whenever someone types http://www.mydomain.com/api/
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /srv/osm3s/cgi-bin/
# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/srv/osm3s/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg
LogLevel warn
CustomLog /var/log/apache2/access.log combined
However when I try to run the command:
http://175.33.148.57/api/interpreter?data=%3Cprint%20mode=%22body%22/%3E
I get the 403 Forbidden error.
I have already done
chmod 777 /srv/osm3s/cgi-bin/
But nothing seems to work.
Please help, Ive been stuck on this for 3 days now! Thanks in advance.

Replace:
Allow from all
by
Require all granted
<Directory /www/mysite>
Allow from All
</Directory>
<Directory /www/mysite>
Require all granted
</Directory>

Here is how I solved this problem for anyone who might have a similar one:
It seemed the problem came from where I installed the overpass installation ($EXEC_DIR).
So I had to change the install directories to:
$EXEC_DIR /var/www/osm/
$DB_DIR /var/www/osm/db/
$PLANET_FILE /var/www/osm/planet.osm.bz2
$REPLICATE_DIR /var/www/osm/rep/
Giving the resulting default.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html
# This directive indicates that whenever someone types http://www.example.com/api/
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /var/www/osm/cgi-bin/
# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/var/www/osm/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
I tried and tried but couldn't get it working with the old dir. Good luck!

try this as it is. don't add Order allow,deny or others
AddHandler cgi-script .cgi .py
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
Allow from all
</Directory>

Related

ProxyPass not overriding .htaccess mod_rewrite

We have an angular app with an apache server which uses .htaccess to rewrite requests to /index.html using
RewriteRule . /index.html [L]
But for a few paths, we want to use /whatever to route to a different domain. However, adding
ProxyPass /whatever whatever.site.com
to sites-enabled doesn't seem to override the .htaccess.
That full file looks like
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
ProxyPass /whatever https://whatever.com
ProxyPassReverse /whatever https://whatever.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Any suggestions?
Also, I know for sure that the sites-enabled file above is being used because if I put garbage-text into it the site crashes ;)
Your quoted virtualhost is probably not used for your test request, because proxy would always bypass mod_rewrite rules specified in .htaccess.
Maybe apachectl -S would give you a hint about which vhosts are present / being used. I see this vhost has no ServerName, so unless it's the first or only *:80 it will probably never be used.

apache invalid command 'ScriptAlias'

I am trying to get apache2 running but no matter what I do, localhost comes up as 404 not found.
There has been so many errors that Debian doesn't even think Apache2 is installed, but it is functional, and running. But I cannot remove it with --purge or otherwise.
When I start apache I get
root#debian:/tmp# /etc/init.d/apache2 restart
Syntax error on line 16 of /etc/apache2/sites-enabled/000-default:
Invalid command 'ScriptAlias', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
failed!
Here is site file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I've tried various configurations. My goal is to utilize multiple IPs for different virtual hosts on port 80, but I haven't even gotten it to work after my last disaster and re installation.
ScriptAlias is provided by mod_alias. On debian based distributions, use a2enmod to make sure mod_alias is loaded:
sudo a2enmod alias

Apache2 virtual host not updating correctly

I have the following as my default virtual host in /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The idea is that it would read the index.html from /var/customers/webs/speed, however, it's still reading the default index.html in /var/www
I have restarted apache and even the server itself, but it just don't seem to want to update.
You must edit /etc/apache2/sites-enabled/default to change default page
If you access http://localhost Apache will load the index.html from Document Root defined in httpd.conf.
If you would like to load Document Root of Virtual Host, try below -
<VirtualHost *:80>
ServerName virtualhost.com
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Go to your Host file and add a new entry 127.0.0.1 virtualhost.com
Apache should now understand which document root to load when you access http://localhost and http://virtualhost.com.
The above code would get you started and then you can add your customization accordingly .
Hope that help!

Apache : client denied by server configuration for some local ressources

i have some troubles to install local website for development.
I have an "client denied by server configuration"' error for some local ressources like .png or .js
My website have following treepath :
website/files
website/app/local
website/app/share
My mainpage is in app/local and can access to files /files but i have 403 error for files in app/share.
I put "chmod -R 777 www-data" on full website directory so what's wrong ?
[SOLVING]I have another little problem : i can't access to my website with localhost/website but only with localhost/
I have reading some tutos and think my following configuration is right (my apache is 2.2) :
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin julien#andcotransport.com
ServerName julien.quai13.com/andcotransport
DocumentRoot /home/julien-quai13/www/andcotransport
#<Directory />
# Options FollowSymLinks
# AllowOverride All
#</Directory>
<Directory /home/julien-quai13/www/andcotransport>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And this my /etc/hosts :
127.0.0.1 localhost
127.0.0.1 julien.quai13.com
127.0.1.1 julien-quai13
192.126.0.34 julien.quai13.com
Not very important but annoying, i always have problems when i switch of Wamp to Linux.
Thanks for helping (promise i stay on Linux this time ;)
Well, when using vhosts, if apache doesn't match the URL with any server name, it will serve the first one it comes to, if this is the first one, then localhost will map straight to /home/julien-quai13/www/andcotransport
You should set up a virtualhost for default with DocumentRoot /home/julien-quai13/www and add a Directory directive for this directory, then localhost/andcotransport will work.
Not sure if this is what you meant to write: chmod -R 777 www-data but this is wrong, commands should be chmod -R 755 /home/julien-quai13/www/andcotransport and chown -R julien-quai13:www-data /home/julien-quai13/www/andcotransport
But permissions wouldn't give you a client denied by server configuration error, this is down to allow being set incorrectly.
Also you have defined julien.quai13.com twice in your hosts file.. one points to 127.0.0.1 and another points to 192.126.0.34.. this may be another problem..
Otherwise i'd consider restructuring your vhosts.
Judging by your vhost:
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory /home/julien-quai13/www>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
You don't actually need the second vhost unless its under a different domaing, like andcotransport.julien.quai13.com so, just use the default domain and pass everything to /andcotransport, if thats how you want to do it...
but make sure all your resources are going to /andcotransport/files and /andcotransport/app/share then this should work, unless you have an overriding ACL somewhere which is blocking directories.

Ubuntu - Apache - Rails - Passenger - Spawning error

I've got the error where passenger complains that:
*** Passenger ERROR (ext/common/ApplicationPool/../SpawnManager.h:220):
Could not start the spawn server: /usr/local/rvm/gems/ruby-1.9.3-head/ruby: No such file or directory (2)
[ pid=8970 thr=139698295748416 file=ext/apache2/Hooks.cpp:865 time=2012-11-07 17:17:32.422 ]: Unexpected error in mod_passenger: Cannot spawn application '/www/lensfinder.se/ruby/lensfinder': Could not read from the spawn server: Connection reset by peer (104)
Backtrace:
in 'virtual Passenger::SessionPtr Passenger::ApplicationPool::Client::get(const Passenger::PoolOptions&)' (Client.h:750)
in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&)' (Hooks.cpp:297)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:566)
From what I can read is that it cant access /www/lensfinder.se/ruby/lensfinder though it exist.
And I found this FAQ on Phusion Passengers site
The problem is that, when I try to use that command,
passenger-config --root
I get this:
-bash: /usr/bin/passenger-config: ruby: bad interpreter: No such file or directory
apache config:
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-head/ruby
<VirtualHost 10.0.0.37:80>
ServerAdmin webmaster#compartment.se
DocumentRoot /www/lensfinder.se/htdocs
ServerName lensfinder.se
Redirect 301 / http://www.lensfinder.se/
ErrorLog /var/log/apache2/lensfinder.se-error.log
CustomLog /var/log/apache2/lensfinder.se-access.log combined
</VirtualHost>
<VirtualHost 10.0.0.37:80>
ServerAdmin hostmaster#compartment.se
ServerName lensfinder.se
ServerAlias www.lensfinder.se
ServerAlias *.lensfinder.se
# DocumentRoot /www/lensfinder.se/htdocs
DocumentRoot /www/lensfinder.se/ruby/lensfinder/script
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /www/lensfinder.se/htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /www/lensfinder.se/cgi-bin/
<Directory "/www/lensfinder.se/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AllowOverride AuthConfig
#Options Includes
#Options FollowSymLinks
#Options +Indexes +Multiviews +FollowSymLinks
</Directory>
<Directory "/www/lensfinder.se/htdocs/usage">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AllowOverride AuthConfig
#Options Includes
#Options FollowSymLinks
#Options +Indexes +Multiviews +FollowSymLinks
</Directory>
ErrorLog /var/log/apache2/lensfinder.se-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/lensfinder.se-access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
Alias /ruby/ /www/lensfinder.se/ruby/lensfinder/script
<Directory /www/lensfinder.se/ruby/lensfinder/script>
# Options ExecCGI
# AddHandler cgi-script .cgi
# Addhandler fastcgi-script .fcgi .fcg .fpl
AllowOVerride all
Order allow,deny
Allow from all
</Directory>
<IfModule passenger_module>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/gems/ruby-1.9.3-head/ruby
</IfModule>
RailsEnv production
RailsBaseURI /script
#
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</Location>
</VirtualHost>
Ok my guess is that you point Passenger to the wrong directory. You should point it to the public directory of your Rails app.
Here's a minimalist configuration for your project that goes in /etc/apache2/sites-available/lensfinder.se:
<VirtualHost 10.0.0.37:80>
ServerAdmin hostmaster#compartment.se
ServerName lensfinder.se
ServerAlias *.lensfinder.se
DocumentRoot /www/lensfinder.se/ruby/lensfinder/public
RailsEnv production
<Directory "/www/lensfinder.se/ruby/lensfinder/public">
Options FollowSymLinks
AllowOverride All
Options -MultiViews
</Directory>
</VirtualHost>
Then edit /etc/apache2/apache2.conf and at the end of the file, add :
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-head/ruby
then simlink your virtualhost config to enable it:
ln -s /etc/apache2/sites-available/lensfinder.se /etc/apache2/sites-enabled/lensfinder.se
And of course restart apache2
In addition to the previous answer, In my case even after editing configuration files I still had issues loading up Apache as the module was still configured to load the previous (global) .so file.
I found there were source files and scripts in the /usr/local/rvm/gems/[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/ext/apache2/ directory, but no binaries. There were however scripts provided to build those. Simply run sudo /usr/local/rvm/gems/ruby-[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/bin/passenger-install-apache2-module.