Serving a WAN IP page

This page is to document how I got server side includes running under OS X 10.3 (should apply to 10.2.x also), and how a simple page can then be used to return a user's WAN IP address. Obviously with server side includes, you have many more options available, and there are links all over the web on interesting things to do, but this will let you get your system up and running, and possibly provide a handy page to serve.

So, let's start with making Apache happy with what we're doing. Edit up your /etc/httpd/httpd.conf file, and about 3/4 of the way through, you'll see the two lines below commented out. Remove the # from each line.


AddType text/html .shtml
AddHandler server-parsed .shtml

Now, you'll need to scroll back a bit to where you set DocumentRoot, if you haven't altered that setting, the lines should look like this:


#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/Library/WebServer/Documents">

Just below that, you'll see a line of Options, you'll want to include the term 'Includes' in that line, as follows:


#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes FollowSymLinks MultiViews Includes

Now, save the altered file. You'll then need to stop and start Web Sharing in the Sharing panel of System Preferences for these settings to take. Now for a sample web page. Just copy the code below into BBEdit or your favorite editor, and save it where you store your web files as wanIP.shtml:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<HEAD>
</HEAD>
<body>
<br/>
Your WAN IP Address is: <!--#echo var="remote_addr" -->
<br />
</body>
</html>


Now that you've saved the file, fire up Safari, or your browser of choice, and pull up the web page from your server, and you should now find that your public WAN IP is displayed, indicating that server side includes are now working.