I have three domains:-
abc.local without ssl configuration
<VirtualHost 10.0.0.87:80>
ServerName abc.local
DocumentRoot /var/www/alpha/abc.local/
ServerAlias hey.abc.local
DirectoryIndex index.php index.html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/alpha/abc.local/>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
ErrorLog /var/log/abc.local/error.log
CustomLog /var/log/abc.local/access.log combined
<Directory /var/www/alpha/abc.local >
AuthType Basic
AuthName abc_test
AuthBasicProvider file
AuthUserFile /var/www/alpha/abc.local/.htpasswd
Require valid-user
</Directory>
</VirtualHost>
test.local with ssl configuration
<VirtualHost 10.0.0.87:80>
ServerName test.local
DocumentRoot /var/www/alpha/test.local/
ServerAlias hey.test.local
DirectoryIndex index.php index.html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/alpha/test.local/>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
ErrorLog /var/log/test.local/error.log
CustomLog /var/log/test.local/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost 10.0.0.87:443>
ServerName test.local
DocumentRoot /var/www/alpha/test.local/
ServerAlias hey.test.local
DirectoryIndex index.php index.html
SSLEngine on
SSLCertificateFile /var/www/alpha/ssl/test.local/test.crt
SSLCertificateKeyFile /var/www/alpha/ssl/test.local/test.key
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/alpha/test.local/>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
ErrorLog /var/log/test.local/error.log
CustomLog /var/log/test.local/access.log combined
SSLHonorCipherOrder On
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5
SSLProtocol all -SSLv2 -SSLv3
</VirtualHost>
</ifModule>
and third one example.local have ssl configuration same like test.local
But issue is when i am trying to access https://abc.local it serving the content of first loaded domain from test.local or example.local
Related
How do I configure my apache settings to serve 3 physical servers on 1 IP address, and on each of those servers exists multiple domains with SSL. I have multi-domain SSL certificates for each server.
Do I need to use the same settings for each httpd file on each physical server?
How do I configure my router for port forwarding?
My current configuration is below. I would appreciate any errors in my settings being brought to my attention and advised how to do it properly.
Server1 httpd:
<Directory />
AllowOverride all
Require all granted
</Directory>
### SERVER1 host ###
<VirtualHost *:80>
DocumentRoot D:/public_html
ServerName server1domain1.org
</VirtualHost>
####################################
#### server1domain1.org VirtualHost ####
<VirtualHost 192.168.1.9:80>
DocumentRoot "D:/public_html/server1domain1.org"
ServerName server1domain1.org
ServerAlias www.server1domain1.org
<Directory "D:/public_html/server1domain1.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server1domain1.org.err"
CustomLog "D:/server/apache/logs/server1domain1.org.log" combined
</VirtualHost>
####################################
#### SSL server1domain1.org VirtualHost ####
<VirtualHost 192.168.1.9:443>
DocumentRoot "D:/public_html/server1domain1.org"
ServerName server1domain1.org
ServerAlias www.server1domain1.org
<Directory "D:/public_html/server1domain1.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server1domain1.org.err"
CustomLog "D:/server/apache/logs/server1domain1.org.log" combined
SSLEngine on
SSLCertificateFile "D:/server/apache/conf/server1domain1.crt"
SSLCertificateKeyFile "D:/server/apache/conf/server1domain1.key"
SSLCertificateChainFile "D:/server/apache/conf/server1domain1-ca_bundle.crt"
</VirtualHost>
####################################
#### server1domain2.org VirtualHost ####
<VirtualHost 192.168.1.9:80>
DocumentRoot "D:/public_html/server1domain2.org"
ServerName server1domain2.org
ServerAlias server1domain2.org
<Directory "D:/public_html/server1domain2.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server1domain2.org.err"
CustomLog "D:/server/apache/logs/server1domain2.org.log" combined
</VirtualHost>
####################################
#### SSL server1domain2.org VirtualHost ####
<VirtualHost 192.168.1.9:443>
DocumentRoot "D:/public_html/server1domain2.org"
ServerName server1domain2.org
ServerAlias server1domain2.org
<Directory "D:/public_html/server1domain2.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server1domain2.org.err"
CustomLog "D:/server/apache/logs/server1domain2.org.log" combined
SSLEngine on
SSLCertificateFile "D:/server/apache/conf/server1domain2.crt"
SSLCertificateKeyFile "D:/server/apache/conf/server1domain2.key"
SSLCertificateChainFile "D:/server/apache/conf/server1domain2-ca_bundle.crt"
</VirtualHost>
***
Server2 httpd
<Directory />
AllowOverride all
Require all granted
</Directory>
### SERVER2 host ###
<VirtualHost server2domain1.com:8081>
DocumentRoot D:/public_html
ServerName server2domain1.com
</VirtualHost>
####################################
#### server2domain1.com VirtualHost ####
<VirtualHost 192.168.1.5:8081>
DocumentRoot "D:/public_html/server2domain1.com"
ServerName server2domain1.com
ServerAlias www.server2domain1.com
<Directory "D:/public_html/server2domain1.com">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server2domain1.com.err"
CustomLog "D:/server/apache/logs/server2domain1.com.log" combined
</VirtualHost>
####################################
#### SSL server2domain2.com VirtualHost ####
<VirtualHost 192.168.1.5:444>
DocumentRoot "D:/public_html/server2domain1.com"
ServerName server2domain1.com
ServerAlias www.server2domain1.com
<Directory "D:/public_html/server2domain1.com">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server2domain1.com.err"
CustomLog "D:/server/apache/logs/server2domain1.com.log" combined
SSLEngine on
SSLCipherSuite ALL:!ADD:!EXPORT56:RC4+RSA:+HIGD:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "D:/server/apache/conf/ssl_crt/server2domain1-multi-certificate.crt"
SSLCertificateChainFile "D:/server/apache/conf/ssl_crt/server2domain1-multi-ca_bundle.crt"
SSLCertificateKeyFile "D:/server/apache/conf/ssl_key/server2domain1-multi-private.key"
</VirtualHost>
####################################
#### server2domain2.org VirtualHost ####
<VirtualHost 192.168.1.5:8081>
DocumentRoot "D:/public_html/server2domain2.org"
ServerName server2domain2.org
ServerAlias www.server2domain2.org
<Directory "D:/public_html/server2domain2.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server2domain2.org.err"
CustomLog "D:/server/apache/logs/server2domain2.org.log" combined
</VirtualHost>
####################################
#### SSL server2domain2.org VirtualHost ####
<VirtualHost 192.168.1.5:444>
DocumentRoot "D:/public_html/server2domain2.org"
ServerName server2domain2.org
ServerAlias www.server2domain2.org
<Directory "D:/public_html/server2domain2.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server2domain2.org.err"
CustomLog "D:/server/apache/logs/server2domain2.org.log" combined
SSLEngine on
SSLCipherSuite ALL:!ADD:!EXPORT56:RC4+RSA:+HIGD:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "D:/server/apache/conf/ssl_crt/server2domain2-multi-certificate.crt"
SSLCertificateChainFile "D:/server/apache/conf/ssl_crt/server2domain2-multi-ca_bundle.crt"
SSLCertificateKeyFile "D:/server/apache/conf/ssl_key/server2domain2-multi-private.key"
</VirtualHost>
***
Server3 httpd
<Directory />
AllowOverride all
Require all granted
</Directory>
### SERVER3 host ###
<VirtualHost 192.168.1.8:8080>
DocumentRoot D:/public_html
ServerName server3domain1.com
</VirtualHost>
####################################
#### server3domain1.com VirtualHost ####
<VirtualHost 192.168.1.8:8080>
DocumentRoot "D:/public_html/server3domain1.com"
ServerName server3domain1.com
ServerAlias www.server3domain1.com
<Directory "D:/public_html/server3domain1.com">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server3domain1.com.err"
CustomLog "D:/server/apache/logs/server3domain1.com.log" combined
</VirtualHost>
####################################
#### SSL server3domain1.com VirtualHost ####
<VirtualHost 192.168.1.8:445>
DocumentRoot "D:/public_html/server3domain1.com"
ServerName server3domain1.com
ServerAlias www.server3domain1.com
<Directory "D:/public_html/server3domain1.com">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server3domain1.com.err"
CustomLog "D:/server/apache/logs/server3domain1.com.log" combined
SSLEngine on
SSLCipherSuite ALL:!ADD:!EXPORT56:RC4+RSA:+HIGD:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "D:/server/apache/conf/ssl_crt/server3domain1-multi-certificate.crt"
SSLCertificateChainFile "D:/server/apache/conf/ssl_crt/server3domain1-multi-ca_bundle.crt"
SSLCertificateKeyFile "D:/server/apache/conf/ssl_key/server3domain1-multi-private.key"
</VirtualHost>
####################################
#### server3domain2.org VirtualHost ####
<VirtualHost 192.168.1.8:8080>
DocumentRoot "D:/public_html/server3domain2.org"
ServerName server3domain2.org
ServerAlias www.server3domain2.org
<Directory "D:/public_html/server3domain2.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server3domain2.org.err"
CustomLog "D:/server/apache/logs/server3domain2.org.log" combined
</VirtualHost>
####################################
#### SSL server3domain2.org VirtualHost ####
<VirtualHost 192.168.1.8:445>
DocumentRoot "D:/public_html/server3domain2.org"
ServerName server3domain2.org
ServerAlias www.server3domain2.org
<Directory "D:/public_html/server3domain2.org">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/server3domain2.org.err"
CustomLog "D:/server/apache/logs/server3domain2.org.log" combined
SSLEngine on
SSLCipherSuite ALL:!ADD:!EXPORT56:RC4+RSA:+HIGD:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "D:/server/apache/conf/ssl_crt/server3domain2-multi-certificate.crt"
SSLCertificateChainFile "D:/server/apache/conf/ssl_crt/server3domain2-multi-ca_bundle.crt"
SSLCertificateKeyFile "D:/server/apache/conf/ssl_key/server3domain2-multi-private.key"
</VirtualHost>
####################################
After doing extensive research and learning that I needed to create a reverse proxy server (FREEDOM.LOCAL), I hired a server expert to set that up for me. After adding "Listen 8080" to my httpd file on the reverse proxy server, the changes that he made to the vhosts.conf file on the reverse proxy server are below:
# Redirect to https
<VirtualHost 192.168.1.8:80>
ServerName freedom.local
ServerAlias *
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
<Location /phpmyadmin>
Require all denied
</Location>
</VirtualHost>
# reverse proxy to TRUTH server
<VirtualHost 192.168.1.8:443>
ServerName domain1.com
ServerAlias www.domain1.com domain1.org www.domain1.org domain2.com www.domain2.com domain2.org www.domain2.org
SSLEngine on
SSLCipherSuite ALL:!ADD:!EXPORT56:RC4+RSA:+HIGD:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "D:/server/apache/conf/ssl_crt/domain1-multi-certificate.crt"
SSLCertificateChainFile "D:/server/apache/conf/ssl_crt/domain1-multi-ca_bundle.crt"
SSLCertificateKeyFile "D:/server/apache/conf/ssl_key/domain1-multi-private.key"
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
Protocols h2 http/1.1
ProxyPreserveHost On
ProxyPass / http://192.168.1.11:80/
ProxyPassReverse / http://192.168.1.11:80/
<Location /phpmyadmin>
Require all denied
</Location>
</VirtualHost>
# reverse proxy to PROSPERITY server
<VirtualHost 192.168.1.8:443>
ServerName domain3.network
ServerAlias www.domain3.social domain3.media www.domain3.media domain3.news www.domain3.news domain3.network www.domain3.network mail.domain3.network domain4.org www.domain4.org domain5.com www.domain5.com
SSLEngine on
SSLCipherSuite ALL:!ADD:!EXPORT56:RC4+RSA:+HIGD:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "D:/server/apache/conf/ssl_crt/domain3-multi.crt"
SSLCertificateChainFile "D:/server/apache/conf/ssl_crt/domain3-multi-ca_bundle.crt"
SSLCertificateKeyFile "D:/server/apache/conf/ssl_key/domain3-multi.key"
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
Protocols h2 http/1.1
ProxyPreserveHost On
ProxyPass / http://192.168.1.13:80/
ProxyPassReverse / http://192.168.1.13:80/
<Location /phpmyadmin>
Require all denied
</Location>
</VirtualHost>
# reverse proxy to PASSION server
<VirtualHost 192.168.1.8:443>
ServerName domain8.org
ServerAlias www.domain8.org domain6.org www.domain6.org domain7.org www.domain7.org
SSLEngine on
SSLCipherSuite ALL:!ADD:!EXPORT56:RC4+RSA:+HIGD:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "D:/server/apache/conf/ssl_crt/multi-domain6.crt"
SSLCertificateChainFile "D:/server/apache/conf/ssl_crt/multi-domain6-ca_bundle.crt"
SSLCertificateKeyFile "D:/server/apache/conf/ssl_key/multi-domain6.key"
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
Protocols h2 http/1.1
ProxyPreserveHost On
ProxyPass / http://192.168.1.9:80/
ProxyPassReverse / http://192.168.1.9:80/
<Location /phpmyadmin>
Require all denied
</Location>
</VirtualHost>
####################################
## PhpMyAdmin
<VirtualHost 192.168.1.8:8080>
DocumentRoot "D:/public_html"
ServerName freedom.local
ServerAlias *
<Directory "D:/public_html">
Options FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
And here is the content of one of the slave servers (PASSION.LOCAL) vhosts.conf file:
<Directory />
AllowOverride all
Require all granted
</Directory>
### PASSION host ###
<VirtualHost 192.168.1.9:80>
DocumentRoot "D:/public_html/domain8.org"
ServerName domain8.org
ServerAlias www.domain8.org
<Directory "D:/public_html/domain8.org">
Options FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/domain8.org.err"
CustomLog "D:/server/apache/logs/domain8.org.log" combined
<IfModule mod_env.c>
SetEnv HTTPS on
</IfModule>
</VirtualHost>
<VirtualHost 192.168.1.9:80>
DocumentRoot "D:/public_html/domain6.org"
ServerName domain6.org
ServerAlias www.domain6.org
<Directory "D:/public_html/domain6.org">
Options FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/domain6.org.err"
CustomLog "D:/server/apache/logs/domain6.org.log" combined
<IfModule mod_env.c>
SetEnv HTTPS on
</IfModule>
</VirtualHost>
<VirtualHost 192.168.1.9:80>
DocumentRoot "D:/public_html/domain7.org"
ServerName domain7.org
ServerAlias www.domain7.org
<Directory "D:/public_html/domain7.org">
Options FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "D:/server/apache/logs/domain7.org.err"
CustomLog "D:/server/apache/logs/domain7.org.log" combined
<IfModule mod_env.c>
SetEnv HTTPS on
</IfModule>
</VirtualHost>
####################################
## PhpMyAdmin
<VirtualHost 192.168.1.9:80>
DocumentRoot "D:/public_html"
ServerName passion.local
ServerAlias *
<Directory "D:/public_html">
Options FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have the following issue with Apache, I am trying to load a website locally, but I get a Forbidden error.
This is my configuration:
/etc/hosts:
127.0.0.1 nop33.local
/etc/apache2/httpd.conf:
Listen 80
<Directory />
Order allow,deny
Require all granted
# AllowOverride none
# Require all denied
</Directory>
DocumentRoot "/Users/nop33/dev"
<Directory "/Users/nop33/dev">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride None
Require all granted
</Directory>
ErrorLog "/private/var/log/apache2/error_log"
/etc/apache2/extra/httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin nop33#example.com
DocumentRoot /Users/nop33/dev/project-name/public
ServerName nop33.local
<Directory /Users/nop33/dev/project-name/public>
Order allow,deny
Require all granted
</Directory>
</VirtualHost>
I need help. I am sorry wrong write. My LAMP server i created virtual host working http://example.com a NOT WORKING http://www.exaple.com
<VirtualHost *:80>
DocumentRoot "/var/www/example/1/public_html"
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster#localhost
<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/
UseCanonicalName on
<Directory "/usr/lib/cgi-bin">
AllowOverride all
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<Directory "/var/www/example/1/public_html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Considering that you have put a local mapping to example.com in /etc/hosts. Do you have same entry for www.example.com also?
example of the /etc/hosts entry:
127.0.0.1 example.com www.example.com
or
xxx.xxx.xxx.xxx example.com www.example.com
(xxx.xxx.xxx.xxx being your hosting server IP)
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
<Directory "C:/xampp/htdocs/">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/gl"
ServerName gl.dev
<Directory "C:/xampp/htdocs/gl">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
The above is what I currently have in my vhosts file. When I hit localhost I want my root to open, but when I load gl.dev I want the individual site to open. Any ideas?
hosts file:
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 gl.dev
I think in windows you have to use backslash when specifying document root. please try the following
<VirtualHost *:80>
ServerName localhost
ServerAlias *.localhost
DocumentRoot "C:\xampp\htdocs\"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gl.dev
ServerAlias *.gl.dev
DocumentRoot "C:\xampp\htdocs\gl"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Restart WAMP server
hello i have 2 domains domain1.com,domain2.com
both are in the same server under domain1.com
i want to set the VirtualHost to handle them both
like this:
<VirtualHost domain1.com:80>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost domain2.com:80>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>.
but for some reason the server send me only to the first one
i also tryed it like this
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>.
anyone have any idea how to fix this problem ?
I think you are missing the NameVirtualHost directive.
NameVirtualHost *:80
<VirtualHost *>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
Without it your first VirtualHost will be used for all access when using name-based virtual hosting.