VIrtual hosts for wild card domain not working

I have configured apache to run alongside with nginx on port 8080.

For some odd reason, I also have a wildcard domain defined at my DNS server, I’ve checked it, and it works(zazazazzaaaz.mysite.com still points to correct IP).

For some odd reason when I am trying to create virtual hosts for sites such as blog.mysite.com or app.mysite.com, it won’t work.

Example VirtualHost code from sites-available dir:

<virtualhost *:8080>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin support@mysite.com
  ServerName  blog1.mysite.com:8080
  ServerAlias blog1.mysite.com:8080

  # Index file and Document Root (where the public files are located)
  DocumentRoot /var/www/vhosts/blog.mysite.com/htdocs/wordpress/
  DirectoryIndex index.php


  # Custom log file locations
  LogLevel warn
  ErrorLog  /var/www/vhosts/blog.mysite.com/log/error.log
  CustomLog /var/www/vhosts/blog.mysite.com/log/access.log combined

</virtualhost>

Thanks in advance!

Answer

A specific error would be helpful. E.g. a description of the page displayed in your browser. Perhaps you are getting a 404, a forbidden message, the default browser “timeout” message.

Here’s a few pointers:

  1. You have specified port 8080 on the servername directive as well as on the Virtualhost directive. While this might not be the source of your problem, it seems pointless. I would remove it.
  2. You have a serverAlias the same as the server name. Again, this seems pointless.
  3. Check that you have adjusted your Listen directive in httpd.conf/apache2.conf so apache is listening on port 8080
  4. If there is a firewall between your webserver and the “outside world” you will need to configure that accordingly.
  5. Check /var/www/vhosts/blog.mysite.com/log/error.log for any indication of the problem.

Attribution
Source : Link , Question Author : Oleg Belousov , Answer Author : GeoSword

Leave a Comment