Y'herd thisun? 

“Soup to Nuts, a complete imaging control and app and all the code that does it (plus a free ebook if you want it). Now that C# does optional parameters this is a simple port for those who aren't bilingual.”

from right here by smith

MONO/Ubuntu part 12 - Subdomains and Christian porn

TaggedASP.Net, MONO, Linux

Remember when we set up the clientside hosts files? On the Vista box we pointed, and all to our new server's IP Address; on the Mac we did the same for,, and

In all the screen shots since creating the asdf site, we've always hit the server using only ""

If you tried a test using the server address after the site was configured you saw why you had to use the www* hosts file value...

But what about using those other host settings?

The clients are doing the correct thing. Based on their host files, all of those urls are being translated to the Ubuntu server's IP Address and the requests are going to the server.

What's more, the server's Apache2 service *is* getting the request host headers correctly. So when the request hits Apache, it is trying to resolve the requested Urls including the subdomains ("maconly.", "test."), or lack thereof in the case of "" .

Because we haven't explicitly told Apache that our asdf site is also the home to all of those subdomains, the service is falling thru to its Default configuration which was created for the "It Works!" page when we installed the Apache service.

It's a SwitchCaseDefault / IfThenElse logic plan.

It's the same thing that happens on a Windows IIS box.

And it's just as simple to fix.

For perspective: On Windows, we go into IIS6 and click our way to the Website Properties->Website Tab -> Web site identification section -> Advanced button -> Add button, or do the cartoony IIS7 direct route of right-clicking the site node and choosing "Edit Bindings" from the popup.

For Apache, we open up the /etc/apache2/sites-available/asdf file with nano and add the ServerAlias setting.

<VirtualHost *:80>
ServerAlias *
DocumentRoot /home/kilgore/sites/asdf
DirectoryIndex  defpage.aspx

You can add as many different subdomains on the line as you want by separating them each with a space, andor you can allow all subdomains by prepending the primary domain value with an asterisk and a dot, as we did in our file.

Also, as with IIS, you can add the IP Address(es) of the machine's nic(s), but just like Windows that can confuse later admins if multiple sites share the same IP address.


Reload Apache so it picks up the changes and try it out. (Safari and Firefox will have to have their caches manually cleared before they'll show the difference, IE defaults to displaying the latest site value.)

A few logicals before we move on:

  • The "*" value does not cover "" because "" does not start with a dot character
  • If you do a client test with a subdomain value that you haven't set up in your client machine's hosts file then you won't hit your ubuntu server because without the value in the hosts file your client machine is going to hit an internet dns server for the IP Address.
  • Before you go-live with the server, you should handle the default IP Address request case. Disabling the default Apache "It Works" site using "a2dissite default" will do it BUT...
    • If your network DNS is resolving site urls to the box and they have a value registered that you haven't set up yet then each request will make Apache go through its list of enabled sites and, not finding a match, the last site in its collection will be used.

      Sooooo, if you have a porn site first and a Christian site to come later, you may not want to tell your DNS administrator about the Christian site until after you have at least a placeholder site set up for it on the server. We're all usually good about this stuff in our SOX-hampered companies but space out on it when pointing multiple Internet domain names to our homeoffice IPs. Do'h!
    • To play it real safe, leave the Apache default site enabled (maybe clean up its configuration settings so it loads lighter) and edit its DirectoryIndex file to be a static dashboard or dummy page.



There's only one downside of being a developer: We know how to use the things we create. That makes testing tough because our fingers (and our browser caches) get trained to type stuff "correctly" instead of the ways that a user will.

Coming next: Curing case sensitiviTy.

jump to:

  • 1: Why?
  • 2: Installation
  • 3: Update the OS with APT
  • 4: Remoting to the box with SSH
  • 5: NANO quickies for 95% of the jobs
  • 6: Firewalling Ubuntu 8.10 Server
  • 7: Installing Apache2 and MONO
  • 8: Test client host files
  • 9: Configure MONO on Apache2
  • 10: Apache default pages
  • 11: Handling Apache and Mono Errors
  • 12: Subdomains and Christian porn
  • 13: Virtual Host Tweak: unmanaged cAse sensitiviTy
  • 14: Managed cAse sensitiviTy
  • 15: Managing files and folders
  • 16: Logging Apache Accesses and Errors
  • 17: Ubuntu Task Managers
  • 18: Ubuntu Services and Service Managers
  • 19: Installing Oracle 10g XE Server
  • 20: Connecting Mono to Oracle

  • home     who is smith    contact smith     rss feed π
    Since 1997 a place for my stuff, and it if helps you too then all the better