Virtual Hosts on Apache2 loading same site for all hosts - apache

I am using Ubuntu 16.04.1 with Apache2.4.7
I enabled both the sites using a2ensite and reloaded apache2. It reloads successfully, but always shows sitea even for siteb.com or www.siteb.com
sitea.conf has following content:
<VirtualHost *:80>
ServerName sitea.com
ServerAlias www.sitea.com
ServerAdmin webmaster#localhost
ServerRoot /home/sitea/
DocumentRoot /home/sitea/www
<Directory /home/sitea/www>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
siteb.conf has following content:
<VirtualHost *:80>
ServerName siteb.com
ServerAlias www.siteb.com
ServerAdmin webmaster#localhost
ServerRoot /home/siteb/
DocumentRoot /home/siteb/www
<Directory /home/siteb/www>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Please suggest what am I doing wrong.

Related

How to defend Apache2 from anti DNS pinning and anti DNS rebinding?

How to defend my apache2 server from anti DNS pinning and anti dns rebinding?
I work in company where is inform safety is important, but they only can test in one platform and tell me where is problem(
I am front-end and do not know how to defend my server ( Madly I hope that you will help with advice and show me the right path! Thank you very much in advance )
This is my
site.name.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName site.name
ServerAlias site.name
DocumentRoot /data/edu3/public
<Directory /data/edu3/>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/apache2/options-ssl-apache.conf
SSLCertificateFile /data/ssl/u1.crt
SSLCertificateKeyFile /data/ssl/u1.key
</VirtualHost>
<VirtualHost *:443>
ServerName catchall
<Location />
Order allow,deny
Deny from all
</Location>
</VirtualHost>
</IfModule>
<VirtualHost 10.224.32.10:80>
ServerAdmin webmaster#localhost
ServerName site.name
DocumentRoot /data/edu3/public
<Directory /data/edu3/>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost _default_:*>
ServerName catchall
<Location />
Order allow,deny
Deny from all
</Location>
</VirtualHost>
<VirtualHost 10.224.32.10:80>
ServerName catchall
<Location />
Order allow,deny
Deny from all
</Location>
</VirtualHost>
The easiest way is to add this virtualhost separately, and make sure that the virtualhost for the main website is using the ServerName directive.
<VirtualHost _default_:80>
ServerAdmin webmaster#localhost
DocumentRoot "/path/to/defaultpagedirectory"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log
</VirtualHost>
Basically what this does is that, it has a default page in the document root (you have to create it), it will serve that default page to the user if the Host header differs.

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

virtual host not working in ubuntu 16.04

I'm working on an Ubuntu 16.04 server with Apache and I'm trying to setup 2 virtual host in the local server(192.168.50.200) . The problem is I don't know how to setup the .conf files correctly. i have created two configuration file in the site_available folder, enabled both configuration file using a2ensite command. And the below IP and URL included in the etc/host file
192.168.50.200 test.site1.com
192.168.50.200 test.site2.com
site1.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName test.site1.com/
DocumentRoot /var/www/site1.com
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
site2.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName test.site2.com
DocumentRoot /var/www/site2.com
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
these configuration links are available in the site_enabled folder.
After these configuration i restrated the apache server and also try to reboot the server but no luck.

Apache2: 2 virtual hosts with subdomains not working

I have set up one conf file in apache with 2 virtual hosts:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName test.domain.com
WSGIScriptAlias / /var/django/test/test/wsgi.py
<Directory /var/django/test/test>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *.80>
ServerAdmin webmaster#localhost
ServerName domain.com
#ServerAlias *.domain.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
But unfortunately only the first one is being called no matter what domain I put into the browser.
My expectation is that only test.domain.com will open my Django project and all other subdomains use the standard website.
What did I do wrong?
Regards
Kev
The error is here:
after replacing the dot wih a ":" the it worked perfekt.

Apache Virtual Host with path

I am deploying a Rails app with Phusion passenger and Apache HTTPD, to do that I have to create a virtual host in Apache to associate the root of my app. And this process is successful, effectively my app is running, but my problem is that I have to do this run in a path of my domain, such as "mydomain.com/railsapp".
I tried this configurations and all failed.**
Configuration 1
ServerAdmin admin#mydomain.com
ServerName mydomain.com/railsapp
RailsEnv production
RailsBaseURI /app
DocumentRoot /var/www/rails/app/public
<Directory /var/www/rails/app/public>
AllowOverride all
Options -MultiViews
#Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Configuration 2
ServerAdmin admin#mydomain.com
ServerName mydomain.com
ServerPath /railsappp
RailsEnv production
RailsBaseURI /app
DocumentRoot /var/www/rails/app/public
<Directory /var/www/rails/app/public>
AllowOverride all
Options -MultiViews
#Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Configuration 3
ServerAdmin admin#mydomain.com
ServerName mydomain.com
ServerAlias mydomain.com/railsappp
RailsEnv production
RailsBaseURI /app
DocumentRoot /var/www/rails/app/public
<Directory /var/www/rails/app/public>
AllowOverride all
Options -MultiViews
#Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Does Anyone have idea how to do that?
Use ServerName as my domain.com and make use of ProxyPass and ProxyPassReverse directive to redirect /railsapp to desired location.... Read more about reverse proxy..