Setting up Name Based VirtualHosts

Kernels & Hardware, configuring network, installing services

Setting up Name Based VirtualHosts

Postby jalisco » 2017-09-02 08:42

Hello Friends,

this seemed like the most logical place to post, but I am aware it is an "admin" type question.

I have a functioning apache2 server configuration, that works fine (www.mysite.com). I wanted to add a subdomain: blog.mysite.com.

I altered the applicable apache2 000-default configuration file to include Virtual hosts. However, the site is not reachable.
I also have added an "A Record" on my DNS service, to also send "blog" -> from my site, to my ip address.

However, the site is unreachable. I will try waiting a few hours to see if it perhaps works later.

Is that basically it? It seems like it should work. It could be that I just need to be more patient with the DNS name resolution.
jalisco
 
Posts: 41
Joined: 2013-09-01 17:30

Re: Setting up Name Based VirtualHosts

Postby kedaha » 2017-09-02 09:51

jalisco wrote:Hello Friends,

Hello jalisco
jalisco wrote:I have a functioning apache2 server configuration, that works fine (http://www.mysite.com). I wanted to add a subdomain: blog.mysite.com.

By the way, it's better to use example.com amd blog.example.com for illustrative purposes rather than the above names. The names you've used belong to a real site.
jalisco wrote:I altered the applicable apache2 000-default configuration file to include Virtual hosts. However, the site is not reachable.
I also have added an "A Record" on my DNS service, to also send "blog" -> from my site, to my ip address.,

However, the site is unreachable. I will try waiting a few hours to see if it perhaps works later.

That's odd. Before posting this, since it's some time since I last did this, I've just set up a subdomain like blog.example.net and I got the Apache2 Debian Default Page confirming "It works!" instantaneously.

I use https, but here's my file in /etc/apache2/sites-available
Code: Select all
# cat 000-default.conf
<VirtualHost *:80>
   # The ServerName directive sets the request scheme, hostname and port that
   # the server uses to identify itself. This is used when creating
   # redirection URLs. In the context of virtual hosts, the ServerName
   # specifies what hostname must appear in the request's Host: header to
   # match this virtual host. For the default virtual host (this file) this
   # value is not decisive as it is used as a last resort host regardless.
   # However, you must set it for any further virtual host explicitly.
   #ServerName server.example.net
   #Redirect permanent / https://server.example.net/webmail
       ServerAdmin webmaster@localhost
   #DocumentRoot /var/www/html

   # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
   # error, crit, alert, emerg.
   # It is also possible to configure the loglevel for particular
   # modules, e.g.
   #LogLevel info ssl:warn

   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined

   # For most configuration files from conf-available/, which are
   # enabled or disabled at a global level, it is possible to
   # include a line for only one particular virtual host. For example the
   # following line enables the CGI configuration for this host only
   # after it has been globally disabled with "a2disconf".
   #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Mate DE & OSSv4.
LaMp, WordPress; ispmail
Debian Stable & Software

Words, as is well known, are the great foes of reality. Joseph Conrad.
User avatar
kedaha
 
Posts: 2789
Joined: 2008-05-24 12:26

Re: Setting up Name Based VirtualHosts

Postby jalisco » 2017-09-02 12:20

Thanks for the quick and informative reply.

I guess there are a few more elements that I didn't mention, that I guess I gotta smooth out. I had hoped they might not play a role, but I guess somewhere along the line, they must.

I have a certificate for my site. I use certbot. Additionally, I already have a configured cloud (nextcloud) setup and running on the domain.

Apparently, going to the park with my child, returning, I actually get sent to the right place =) My server, finally, but now gotta figure out the issue locally.

Thanks again,
Jalisco
jalisco
 
Posts: 41
Joined: 2013-09-01 17:30

Re: Setting up Name Based VirtualHosts

Postby kedaha » 2017-09-02 13:47

I'd be interested to hear how it goes so please post again.

I remember reading in one of your topics that you were interested in setting up a mail server as, for example at workaround.org. In case it interests you, I'd just like to mention that I've hit upon a way to use Letsencrypt (LE) for both the blog—in my case, wordpress site—and the email from the same virtual domain, with only one IP address, as I posted at viewtopic.php?f=3&t=134383#p653470. The problem is that a self-issued certificate for the email and a LE certificate for the web server are incompatible so if you have the same problem, the solution is to use only one LE certificate for both.

For setting up virtual hosts I use the howto at how-to-set-up-apache-virtual-hosts-on-debian-8/].
Mate DE & OSSv4.
LaMp, WordPress; ispmail
Debian Stable & Software

Words, as is well known, are the great foes of reality. Joseph Conrad.
User avatar
kedaha
 
Posts: 2789
Joined: 2008-05-24 12:26


Return to System configuration

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable