2

I had this sorted out before, but now I had to wipe my VPS and apparently I can't configure stuff properly anymore, so..

I've set up a Debian VPS and installed Virtualmin on it I bought a test domain to use with that VPS and pointed its main A DNS to my VPS IP I used Virtualmin to create a virtual server for the root domain, let's say example.org, but whenever I opened the URL I'd get the default virtualhost page I proceeded to delete the default VH (not the ACTUAL default, just one that Virtualmin created) and I still get pointed to /var/www instead of /home/example/public_html Ignoring this, I tried creating a subdomain hoping that at least this one would've pointed to the correct directoy, but nothing worked (I created the *.example.org CNAME DNS as well, all pointing to example.org, is that correct?)

Here's the VH file that Virtualmin created:

<VirtualHost 127.0.0.2:80>
SuexecUserGroup "#1001" "#1001"
ServerName example.org
ServerAlias www.example.org
ServerAlias webmail.example.org
ServerAlias admin.example.org
DocumentRoot /home/example/public_html
ErrorLog /var/log/virtualmin/example.org_error_log
CustomLog /var/log/virtualmin/example.org_access_log combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/example/public_html>
  Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
  allow from all
  AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
  AddType application/x-httpd-php .php
  AddHandler fcgid-script .php
  AddHandler fcgid-script .php5
  FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php
  FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php5
</Directory>

<Directory /home/example/cgi-bin>
  allow from all
  AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.example.org
RewriteRule ^(.*) https://example.org:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.example.org
RewriteRule ^(.*) https://example.org:10000/ [R]

RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
IPCCommTimeout 31
FcgidMaxRequestLen 1073741824
Alias /pipermail /var/lib/mailman/archives/public
RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://example.org:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://example.org:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
</VirtualHost>

Apprently, the default-ss.conf configuration is used for any sort of request, but I can't figure out why, since it begins with "VirtualHost default:443" and I'm requesting on the default 80 port

3

2 Answers 2

4

I found the problem, in case anyone else ends up with a similar scenario:

<VirtualHost 127.0.0.2:80>

I had to change this to the actual server's IP because, for some reason, Virtualmin didn't pick it up on its own during the setup process

3
  • 1
    @Reaces A new/low-rep user needs to wait 48 hours before they can do that. I really hope mdk will come back and do it, and also hang around and ask/answer more questions.
    – Jenny D
    Jan 29, 2015 at 12:02
  • 1
    Or if your website has only 1 IP address and you're doing Name-Based Virtual Hosts, <VirtualHost *:80> which will save you more headaches the day your IP changes (you migrate to a new server, etc.)
    – Calimo
    Jan 29, 2015 at 13:32
  • Will fix that right away thanks, and yes, can't accept my answer for a couple more days... I'll hopefully remember to come back to this, although I'm more often on stackoverflow than here
    – Mdk
    Jan 29, 2015 at 22:49
1

As you identified in your answer, the problem was that you were setting the virtual host to listen to IP 127.0.0.2, which your visitors were not using (they were using the server's public IP).

You then changed it to the server's public IP so it now works, but it will stop working the day your IP changes (you migrate to a new server, your host is migrated to an other zone on a different network, you copy this to a new server, etc.)

A better solution for a name-based virtual host is to define no IP, and use a wildcard instead:

<VirtualHost *:80>

Not the answer you're looking for? Browse other questions tagged .