CakePHP - Apache un-htpasswd certain path - apache

I have a CakePHP application still in development.
Our server has a password protection done through the apache vhost file.
e.g
<Directory "/var/www/vhosts/project">
Order deny,allow
Deny from all
AuthType Basic AuthUserFile /etc/httpd/conf/htpasswd
AuthName "Authorized users only!"
...
</Directory>
Now, I'm trying to open up certain path. e.g http://project.com/shares/*
This is the virtualhost setup
<VirtualHost *:80>
DocumentRoot /var/to/cakephp/app
Options FollowSymLinks
ServerName project.com
ServerAdmin ...
DirectoryIndex index.php index.jsp index.htm index.html
ErrorLog ...
CustomLog ...
</VirtualHost>
How can I do that?
Doing this just removes the whole password protection
<Directory "/var/to/cakephp/app">
Options All
AuthType None
AllowOverride All
Order allow,deny
Allow from all
</Directory>
And I can't just do
<Directory "/var/to/cakephp/app/shares">
</Directory>
Basically the htaccess is messing with me now.
Thank you,
Tee

Just add another directory , and add something like this :
<Directory /var/www/vhosts/project/shares/>
Order Allow,Deny
Satisfy Any
Allow from all
Options Indexes
</Directory>
Use the Options you need.
http://httpd.apache.org/docs/2.0/mod/core.html#satisfy

Related

Apache LDAP Authentication only for some virtualhosts

I have a webserver running Apache 2.4.6 under CentOS 7 in which I have several web resources. I want to apply LDAP authentication only to some of them, so I am trying to do it by creating a single virtualhost for every resource and configure the LDAP authentication only to the resources I want.
This is my attempt:
/etc/httpd/conf.d/test1.conf:
<VirtualHost *:80>
Servername server_name
DocumentRoot /var/www/html/test1
<Directory "/var/www/html/test1">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
#LDAP
SetHandler php-script
Require all denied
AuthBasicProvider ldap
AuthUserFile /dev/null
AuthName "ldap_auth"
AuthType Basic
AuthLDAPURL ldap_url
AuthLDAPBindDN ldap_dn
AuthLDAPBindPassword ldap_pass
Require ldap-group ldap_group
</Directory>
</VirtualHost>
/etc/httpd/conf.d/test2.conf:
<VirtualHost *:80>
Servername server_name
DocumentRoot /var/www/html/test2
<Directory "/var/www/html/test2">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This is the relevant information of my current httpd.conf file:
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
IncludeOptional conf.d/*.conf
But it always asks for authentication for both test1 and test2 and for test2 I am not even able to load the content after logged in (test1 loads fine).
Finally achieved by using Alias directive, so:
/etc/httpd/conf.d/test1.conf:
<VirtualHost *:80>
Servername server_name
DocumentRoot /var/www/html/test1
Alias /test1 /var/www/html/test1
<Directory "/var/www/html/test1">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
#LDAP
SetHandler php-script
Require all denied
AuthBasicProvider ldap
AuthUserFile /dev/null
AuthName "ldap_auth"
AuthType Basic
AuthLDAPURL ldap_url
AuthLDAPBindDN ldap_dn
AuthLDAPBindPassword ldap_pass
Require ldap-group ldap_group
</Directory>
</VirtualHost>
/etc/httpd/conf.d/test2.conf:
<VirtualHost *:80>
Servername server_name
DocumentRoot /var/www/html/test2
Alias /test2 /var/www/html/test2
<Directory "/var/www/html/test2">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Apache The Requested URL has not been found on this server

So, I'm trying to get Codiad on my VPS so that me and a friend can work on a project together, and when I try to index localhost/codiad it gives me this error:
The requested URL /codiad was not found on this server.
however, indexing localhost works perfectly fine, it leads me to the normal apache screen. Here are the contents of my default.conf file, if that helps at all:
<VirtualHost *:80>
ServerName www.dsept.cf
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /codiad /home/Tide/Codiad
<Directory "/home/Tide/Codiad">
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
I'm also following this guide if that helps too: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-codiad-a-web-based-ide-on-an-ubuntu-vps, the directory of default.conf is /etc/apache2/sites-available/default.conf
1) are you sure there should be:
localhost/codiad
or :
localhost/Codiad
2) have you ever changed that .conf? If so, you may have to edit that .conf and add codiad alias/path correctly. Is everything accurate there?

apache AllowOverride /var/www/html but not /var/www/html/temp/

I have a wordpress site, Because wordpress need .htaccess rule, so /var/www/html should be set AllowOverride all. But I have some custom folder /var/www/html/temp/, it has many sub-folder, the max depth could be 9. /var/www/html/temp/images/avatar/username/large/cache/image.jpeg. How to add another rule, so that <directory "/var/www/html/temp"> could be with rule AllowOverride None,thanks.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
<directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>
There's not really a trick here, if you create a 2nd directory section that is conceptually below the first, its changes will be merged in:
<Directory "/var/www/html/temp">
AllowOverride None
</Directory>
For clarity, just put it immediately after the existing Directory section, although for Directory that is not strictly necessary.
You should review the basics of the "configuration sections" topic in the manual.

2 domains pointing to 1 server (2 different subfolders)

OK, so, I think the title is rather self-explanatory.
I've set up my own Apache server (on Debian) and hosting 2 different sites (let's say mysite1.com at /home/www/mysite1, and mysite2.com at /home/www/mysite2).
In my domain name registrar setup page (Dynadot actually), I created A records (still not sure what this is exactly...) for both of them, pointing to my server's ip...
Now, on the server's side, here'e what my .conf file looks like (/etc/apache2/sites-enabled/mysite actually)
<VirtualHost *:80>
DocumentRoot /home/www/mysite1.com
ServerName www.mysite1.com
ServerAdmin drkameleon#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/www/mysite1.com>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin
<Directory "/home/www/mysite1.com/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot /home/www/phpmyadmin
ServerName www.mysite1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/www/mysite2.com
ServerName www.mysite2.com
ServerAdmin drkameleon#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/www/mysite2.com>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Now, the thing is. Now matter which site I visit (1 or 2), I always get mysite1's contents.
What am I doing wrong? Any ideas?
There are multiple possibilities of what could go wrong.
Do you have
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
somewhere in the config? (http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost)
Without that config entry Apache is not sensitive to domain names in dispatching requests to virtual hosts.
It's just a guess.
Make sure Apache has been reloaded after any changes to the config!

Apache Config for PHP and Web2Py

I'm setting up a server for home to run all sorts of things. I'll save you the whole story, but I'm trying to get it to run Web2Py through WSGI, but also need to serve PHP files for other web apps I have. I tried the install script for Web2Py, but that "hijacked" the entire Apache system to run the Web2Py system.
The setup currently works for PHP and SSL pages, but I cannot get it to also process requests for the Web2Py site. For the Web2Py url (http://jupiter/web2py), I get an Apache directory listing. Please help.
The directory structure is this:
/var/www --> Apache DocumentRoot
/var/www/scripts --> various PHP scripts
/var/www/web2py --> Web2Py
The /etc/apache2/sites-available/default file is setup as this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin me#yahoo.com
ServerName jupiter.myhome.com
WSGIDaemonProcess web2py user=www-data group=www-data display-name=%{GROUP}
WSGIProcessGroup web2py
WSGIScriptAlias /web2py /var/www/web2py/wsgihandler.py
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>
<Directory /var/www/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(.*) /var/www/web2py/applications/$1/static/$2
<Directory /var/www/web2py/applications/*/static/>
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
#comment
#comment
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
I successfully configured a Joomla (PHP) application + Web2py. Your apache config seems ok. Just make sure you configure your /web2py/routes.py with the correct path_prefix (as per your example it should be 'web2py'):
routers = dict(
BASE = dict(
default_application='<your_default_app>',
path_prefix='web2py',
)
)