Apache - vHost - Forbidden - apache

I am trying to make a vhost that point "*:9090" to a specific directory. I'll explain.
That print below shows it's working the path i want.
So, I am trying to do "*:9090" point to this path (/wamp/www/root/dev). Below what i tried.
<VirtualHost *:9090>
DocumentRoot "c:/wamp/www/root/dev"
<Directory c:/wamp/www/root/dev>
Options all
Allow from all
AllowOverride All
Require all granted
</Directory>
And now, below, a print of my result.
What am i doing wrong?

I had the same issue until I used this:
<Virtualhost *:80 >
ServerName site.domain.com
DocumentRoot /path/to/site
<Directory /path/to/site>
AllowOverride All
Require all granted
</Directory>
ServerAdmin user#domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</Virtualhost>

Related

How to use different Flask template directory from Apache VirtualHost

I want to serve up different 'look' and content for users on my flask site based on the virtualhost they use to reach the site without duplicating the entire code tree.
E.g. going to red.mysite.com would serve up red pages and 'red' content where the default is white.
I can do this today for the look using using a custom static tree in the Apache config to se the css and images but I want to have a custom /template tree too so I can change the page content in my templates to 'Red' versions.
Is there a way to set template dir from VirtualHost directives like with /static?
<VirtualHost *:80>
ServerName mysite.com
ServerAdmin admin#mywebsite.com
WSGIScriptAlias / /var/www/mysite.wsgi
<Directory /var/www/mysite/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/mysite/static
<Directory /var/www/mysite/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName red.mysite.com
ServerAdmin admin#mywebsite.com
WSGIScriptAlias / /var/www/mysite.wsgi
<Directory /var/www/mysite/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/mysite/red/static
<Directory /var/www/mysite/red/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Graham pointed me down the right path.
Here is how I did it:
changed conf to add in processgroup
<VirtualHost *:80>
ServerName mysite.com
ServerAdmin admin#mywebsite.com
WSGIDaemonProcess default
WSGIProcessGroup default
WSGIScriptAlias / /var/www/mysite.wsgi
<Directory /var/www/mysite/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/mysite/static
<Directory /var/www/mysite/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName red.mysite.com
ServerAdmin admin#mywebsite.com
WSGIDaemonProcess red
WSGIProcessGroup red
WSGIScriptAlias / /var/www/mysite.wsgi
<Directory /var/www/mysite/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/mysite/red/static
<Directory /var/www/mysite/red/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Modified Flask app creation as follows:
import mod_wsgi
instance = mod_wsgi.process_group
if instance == 'red':
app = Flask(__name__, template_folder='red/templates')
else:
app = Flask(__name__)
Now anyone coming in on the 'Red' URL sees templates in red/templates.
Bill

Apache virtualhost servername by ip + documentroot

I am trying to get this virtualhost working on apache + ubuntu. I want it to work without a real domainname but by ip and the path. It is now not getting activated. Is it possible to use the serverName like this or are only domain names valid?
<VirtualHost *:80>
serverName 37.35.66.98/just-do-it/
DocumentRoot /var/www/html/just-do-it/web
<Directory /var/www/html/just-do-it/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Remove path portion from server name, then this should work
<VirtualHost *:80>
serverName 37.35.66.98
DocumentRoot /var/www/html/just-do-it/web
<Directory /var/www/html/just-do-it/web>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
do not forget to add your server name in /etc/hosts file

you don't have permission to access / on this server. apache 2.4

I'm having the problem
you don't have permission to access / on this server. apache 2.4
while accessing my local web site. I already googled a lot and read a lot of posts here in StackOverflow and everything seems to be correct.
This is my apache version:
Server version: Apache/2.4.27 (Unix)
Attached my httpd.conf file.
Here is my httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost.smatchme.com
DocumentRoot "/Users/samuelrabini/Project/SmatchMe/smatchme.web"
ServerName localhost.smatchme.com
<Directory /Users/samuelrabini/Project/SmatchMe/smatchme.web>
Require all granted
Options Includes FollowSymLinks
AllowOverride All
</Directory>
DirectoryIndex index.php
ErrorLog "/private/var/log/apache2/localhost.smatchme.com-error_log"
CustomLog "/private/var/log/apache2/localhost.smatchme.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost.piuproduct.com
DocumentRoot "/Library/WebServer/Documents/piuproduct/public"
ServerName localhost.piuproduct.com
<Directory /Library/WebServer/Documents/piuproduct>
Require all granted
Options Includes FollowSymLinks
AllowOverride All
</Directory>
ErrorLog "/private/var/log/apache2/localhost.piuproduct.com-error_log"
CustomLog "/private/var/log/apache2/localhost.piuproduct.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost.b2b.com
DocumentRoot "/Library/WebServer/Documents/b2b.tony"
ServerName localhost.b2b.com
<Directory /Library/WebServer/Documents/b2b.tony>
AllowOverride All
Require all granted
</Directory>
ErrorLog "/private/var/log/apache2/localhost.b2b.com-error_log"
CustomLog "/private/var/log/apache2/localhost.b2b.com-access_log" common
</VirtualHost>
Can anyone help me understand what I'm doing wrong?
I'm trying to access my site via http://localhost.b2b.com/
And I added in the /etc/hosts the entry:
127.0.0.1 localhost.b2b.com
thanks in advance
Samuel

403 Forbidden vhost Ubuntu

Trying to setup my webserver and allow .htaccess in all www directories. When accessing sub.domain.com on my laptop (with host files adjusted), returns a 403 Forbidden. "You don't have permission to access / on this server."
It feels like the .htaccess file is not allowed, and therefore throws the 403. But as per my understanding the settings are correct isn't? Am I overlooking something?
apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
AllowOverride All
</Directory>
domain.com.conf
<VirtualHost *:80>
ServerName domain.com
ServerAlias sub.domain.com
ServerAdmin webmaster#domain.com
DocumentRoot /var/www/domain.com/public_html/support/current
<Directory "/var/www/domain.com/public_html/support/current">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName domain.com
ServerAlias .domain.com
ServerAdmin webmaster#domain.com
DocumentRoot /var/www/domain.com/public_html/support/current
<Directory "/var/www/domain.com/public_html/support/current">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Either /var/www/domain.com/public_html/support/current doesn't exist, or its rights are not correct for user Apache runs on. Check the User and Group settings in the main Apache config to find out what they are.
You might also want to check the error log to get additional clues.

AllowOverride not allowed here

I have setup a virtualhost like following
<VirtualHost *:80>
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options Includes
AllowOverride All
</VirtualHost>
But always throws me
AH00526: Syntax error on line 6 of /etc/apache2/sites-enabled/000-my-site.conf:
AllowOverride not allowed here
I'm a bit confused because I understand that is the right place to do it
It's because you have to put it in <Directory> directive.' .htaccess is per directory context, so you have to explicitly tell apache where .htaccess is allowed to be used.
<VirtualHost *:80>
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options Includes
<Directory "/var/www/html">
AllowOverride All
</Directory>
</VirtualHost>