Question

Apache2 - Vhost keep redirect to https vhost, and not the request vhost

Posted October 10, 2013 24.3k views
i am facing an issue with my vHost setup which I rly can't figure out how to fix First my vhost config: ServerName dnsmaster.*****.com:80 DocumentRoot /var/www/dns Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined ServerName chat.*****.com:443 DocumentRoot /var/www/chat Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key Both vHost are located in the default file (000-default) - Also this is all there is in that file. The first vHost works fine, and are also working with SSL/HTTPS but when I try to go to second vHost, then it redirects me to the first one. I've never faced this problem before, and have been setting a few vHosts up in the past. But never 2 vHost where one is HTTPS and the other is HTTP also this is the ports.conf: (default) NameVirtualHost *:80 Listen 80 NameVirtualHost *:443 Listen 443 Listen 443

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
15 answers
Have you followed the steps outlined in this guide: How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTS

Also, make sure you have the mod_ssl module enabled. See HTTPS Configuration.
by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one domain off of a single IP address and allows you to run multiple sites off of a single DigitalOcean droplet. This tutorial describes how to set up virtual hosts with Apache.
Hello Pablo,

Yes, all that is done :)
Hmm... in what directory did you save your SSL certificate? Also, I wonder if the "*" in NameVirtualHost *:443 needs to be changed to the FQDN or IP address assigned to your SSL certificate?
Hello Pablo,

I've tried editing the NameVirtualHost *:443 to both IP and FQDN, didn't work either.
They are saved in /etc/apache2/ssl/
The problem isn't the HTTPS/SSL Site, the problem is the non-sll/HTTP site, if I go to that one, it redirects me to the HTPPS/SSL site
Why not separate the two vHosts, instead of having them in the same 000-default file?
Because that doesn't work either :/
What happens when you visit:

  1. http://chat.***.com
  2. https://chat.***.com
  3. http://dnsmaster.***.com
  4. https://dnsmaster.***.com
Hello Kamal,

All 4 goes to https//chat.****.com
forgot:

If I go to #4 https://dnsmaster.***.com - the URL is then still https://dnsmaster.***.com, but still goes to chat.****.com site
Previous 1 2 Next