Hosting Multiple Namebased VirtualHosts with SSL
Posted: 24. September 2004 09:20
HOW TO USE XAMPP TO HOST MULTIPLE DOMAINS, ALOWING ALL THE DOMAINS TO HAVE BOTH NON-SSL(http://...) AND SSL(https://...) CAPABILITY?
For the past several days, I've been trying to host multiple name based vhosts using xampp. No one was any help. I read almost the entire apache 2.0 docs, and openSSL, mod_SSL docs. Finally, I succeeded ... I must have re-written the whole httpd.conf and ssl.conf files over 10x. I hope all the pain I went through will help you save time.
Just add the below to the end of your httpd.conf file as needed and it should work. You can just keep adding VirtualHosts with different ServerName and DocumentRoot directives.
-----------------add to http.conf---------------------------
# Use name-based virtual hosting, add your own ip,
# find your IP by going to start>run>cmd and type ipconfig /all.
NameVirtualHost 192.168..0.1:80
NameVirtualHost 192.168.0.1:443
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
###### DOMAIN1 non SSL ###########
<VirtualHost 192.168.0.1:80>
DocumentRoot "C:/xampp/htdocs/path2domain1"
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
# If you need domain specific Error or access logs
# ErrorLog logs/domain1_error.log
# CustomLog logs/domain1_access.log common
</VirtualHost>
### SSL FOR THE SAME DOMAIN1 ####
<VirtualHost 192.168.0.1:443>
# General setup for the virtual host
DocumentRoot "C:/xampp/htdocs/_test/catalog"
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
ServerAdmin you@your.address
#If you need domain/SSL specific error and access logs
ErrorLog logs/domain1_sslerror.log
TransferLog logs/domain1_sslaccess.log
#SSL Engine Switch (on|off):
SSLEngine on
# Server Certificate:
SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
# Server Private Key:
SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"
# Below <Directory> only needed if you want to secure a directory with user
# authentication. Change options as needed.
# Read http://httpd.apache.org/docs-2.0/howto/auth.html
# <Directory "C:/xampp/htdocs/path2domain1">
# AuthType Basic
# AuthName "Restricted Stuff here"
# AuthUserFile "C:/xampp/apache/bin/passwd/passwords
# Require user yourNameHere
# </Directory>
</VirtualHost>
--------------------------THE END----------------------
Hope this helps ... if so, write a quick thank you note below! pass on your knowlege. Give and ye shall receive.
For the past several days, I've been trying to host multiple name based vhosts using xampp. No one was any help. I read almost the entire apache 2.0 docs, and openSSL, mod_SSL docs. Finally, I succeeded ... I must have re-written the whole httpd.conf and ssl.conf files over 10x. I hope all the pain I went through will help you save time.
Just add the below to the end of your httpd.conf file as needed and it should work. You can just keep adding VirtualHosts with different ServerName and DocumentRoot directives.
-----------------add to http.conf---------------------------
# Use name-based virtual hosting, add your own ip,
# find your IP by going to start>run>cmd and type ipconfig /all.
NameVirtualHost 192.168..0.1:80
NameVirtualHost 192.168.0.1:443
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
###### DOMAIN1 non SSL ###########
<VirtualHost 192.168.0.1:80>
DocumentRoot "C:/xampp/htdocs/path2domain1"
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
# If you need domain specific Error or access logs
# ErrorLog logs/domain1_error.log
# CustomLog logs/domain1_access.log common
</VirtualHost>
### SSL FOR THE SAME DOMAIN1 ####
<VirtualHost 192.168.0.1:443>
# General setup for the virtual host
DocumentRoot "C:/xampp/htdocs/_test/catalog"
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
ServerAdmin you@your.address
#If you need domain/SSL specific error and access logs
ErrorLog logs/domain1_sslerror.log
TransferLog logs/domain1_sslaccess.log
#SSL Engine Switch (on|off):
SSLEngine on
# Server Certificate:
SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
# Server Private Key:
SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"
# Below <Directory> only needed if you want to secure a directory with user
# authentication. Change options as needed.
# Read http://httpd.apache.org/docs-2.0/howto/auth.html
# <Directory "C:/xampp/htdocs/path2domain1">
# AuthType Basic
# AuthName "Restricted Stuff here"
# AuthUserFile "C:/xampp/apache/bin/passwd/passwords
# Require user yourNameHere
# </Directory>
</VirtualHost>
--------------------------THE END----------------------
Hope this helps ... if so, write a quick thank you note below! pass on your knowlege. Give and ye shall receive.