Monday, August 10, 2009

Apache2 configuration for VMWare Server 2

I've extracted this from my notes on setting up Apache2 to allow multiple IP aliases on a single IP address to point to multiple virtual machines. Mostly this post is to allow me fast access for setting up other machines.

Background info - this is setup on Ubuntu 9.04, using VMWare Server 2 and Apache2. For VMWare, I'm using bridged networking and ignoring VMWare's NAT networking capabilities (I found that it was very poorly documented to configure it easily). Basically, the host machine redirects all incoming port 80 traffic to the the Apache web server, which then gets split depending on the ip alias it is using. All modern web browsers (i.e. pretty much anything that came out in the past several years) will view the web sites correctly - old browsers do not send the alias, so will only see the first machine listed.

Make sure proxy packages are installed and enabled:
/etc/apache2/mods-available
/etc/apache2/mods-enabled (symbolic links to files in /etc/apache2/mods-available)

Packages Needed: proxy.conf, proxy_html.conf, proxy_html.load,proxy_http.load, proxy.load

Edit /etc/apache2/mods-available/proxy.conf from “Deny from all” to “Allow from all”

In /etc/apache2/sites-available/, copy “default” to “default.bak”, then edit “default” to be set up for the proxy:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName vbox1.hostname.com
ProxyPass / http://192.168.1.150/
ProxyPassReverse / http://192.168.1.150/
</virtualhost>

<VirtualHost *:80>
ServerName vbox2.
hostname.com
ProxyPass / http://192.168.1.151/
ProxyPassReverse / http://192.168.1.151/
</virtualhost>

<VirtualHost *:80>
ServerName vbox3.
hostname.com
ProxyPass / http://192.168.1.152/
ProxyPassReverse / http://192.168.1.152/
</virtualhost>
Note the slash after the virtual internal ip address – it is needed!

Restart Apache2 (/etc/init.d/apache2 restart)

Reference websites/blogs/forumns:
http://www.livingubuntu.com/?p=77
http://www.apachetutor.org/admin/reverseproxies
http://ubuntuforums.org/showthread.php?t=358687
http://serendipity.ruwenzori.net/index.php/2006/12/24/proxy-no-protocol-handler-was-valid-for-the-url
http://ubuntuforums.org/showthread.php?p=1852061#post1852061
http://httpd.apache.org/docs/2.0/vhosts/name-based.html

Tuesday, April 14, 2009

MS manages to screw up (Again!)

I'm learning how to use Microsoft's relatively new data interface called LINQ, which is designed to allow developers to treat different data types (like XML files, and databases) and data queries (such as SQL queries) as objects. This in theory allows the developer to be able to debug data queries at compile time have better knowledge of what is happening during runtime.

The problem is that Microsoft forgot that a lot of web application development uses its SQL Server db as a backend. Now, SQL Server is a mature product and the basic data types that it incorporates have not changed for a significant time.

The problem I've been happening deals with integers:
  • tinyint (8-bit) - 0 - 255
  • smallint (16-bit) -2^15 (-32,768) to 2^15-1 (32,767)
  • int (32-bit) - -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)
I use the tinyint for lookup tables where there will be a very limited number of items. In this case, it was a table for status, which currently has two items, active and inactive.

Now, for LINQ, you can manually define your tables as a class. So, my status table looked like this:

[Table(Name = "Status")]
public class t_Status
{
[Column(IsPrimaryKey = true)]
public int statusID;

[Column]
public string type;

private EntitySet _staLU;
[Association(Storage = "_staLU", OtherKey = "statusID")]
public EntitySet StatLU
{
get { return this._staLU; }
set { this._staLU.Assign(value); }
}
}

So when I try to use this I get a "specified cast is not valid". After some searching on Google, I find that LINQ doesnt automatically convert between the various int types. I can understand this from a big to small perspective - you would not want to lose digits/accuracy. But for small to big? It should be able to automatically figure that out in the background.

Further annoyance was found when I discovered I can't even easily assign the tinyint as a proper type in C# - I can with smallint by using public int16 statusID; but that means effectively I have to use a less efficient (memory wise), larger type in my database to be able to use LINQ.

It seems to me that Microsoft should have thought this through - DBAs are not going to be happy having to redesign databases to accomodate this miss.