Making Tracks publicly accessible
A couple of people have asked on the wiki how you set up Tracks so that you can access it from other computers. The answer depends a little on how you have your computer networked, and on the platform you are running on.
Setting up Apache isn’t something I’ll cover in detail. There’s plenty of documentation on the Apache site, and many *nix based distributions come with it pre-installed. If you’re on MacOS X, it’s very easy. Just go to System Preferences > Sharing and check the box next to ‘Personal Web Sharing’. After a few seconds, you’ll get confirmation of the URL from which you can access your sites at the bottom of the window. Try using it to make sure that you get the default index.html welcome message, showing that Apache is working.
Now the tricky part is the IP address of your machine. If you’re running it on a machine which has a stable domain name, there’s no problem; you just enter http://your.domain.tld/ as the first part of the URL. However, if like most people you’re using a computer on a cable or ADSL modem, you probably just have an IP address, which is likely to be assigned dynamically, and will therefore change over time. Worse, you might be using a router or an Airport Base Station which is distributing local IP addresses (like 10.0.x.x or 192.168.x.x) to the machines on the local network. That means that it’s going to be difficult to access from outside your network. In the case of machines sitting behind a router, I think it is possible to tunnel connections through to local IP addresses (so that a call to the external IP gets routed to an internal IP), but it’s complicated and can compromise the security of your network. You’d probably be better off thinking about getting your Tracks installation hosted by a hosting company in that case.
If you have a dynamic IP which isn’t a local one, you can use DynDNS to help you track the changing IP address so that you can always connect to your computer remotely. I haven’t tried it myself, but I’ve heard that it works quite well.
If you have a static IP, there shouldn’t be any problems. First, you need to make sure that your Apache config file (/etc/httpd/httpd.conf on MacOS X) is set up to handle .cgi files. Somewhere in the config file, make sure that you have this line:
AddHandler cgi-script .cgi
You’ll probably find that the line is in there but commented out with #; just remove the #, save the file and restart Apache, and you should be fine. Then you need to make a few other changes to httpd.conf and .htaccess (in tracks/public) to make things run smoothly. There’s a very clear explanation here. The crucial step is making sure that you make an alias which points to the public directory within the tracks directory. You might find it easier to use what’s called a VHost installation, in which case follow the instructions at the bottom of this page.
It’s worth checking tracks/log/apache.log if you encounter errors to try to debug it. One last thing: by default, the setup runs in ‘development’ mode, which means that you don’t have to restart the server to see changes as a result of editing the source code. This is fine for development, but it’s a bit slower. Once you’ve got things set up, you probably want to change a line in tracks/config/environment.rb. Change line 2 in that file from:
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
to
RAILS_ENV = ENV['RAILS_ENV'] || 'production'
I’ll probably make this the default in future releases.
Well, I hope that this brief explanation helps a little. I would say that running your own externally accessible server isn’t trivial, and you do have to worry about the security of your machine, and of course make sure that it’s running all the time. For many people (particularly those like me who are behind a router), it makes much more sense to find a good web host who will take care of all those worries for you. I host my own working Tracks installation on TextDrive, and I recommend them unreservedly.
Filed under: tips



Sat, 12 Feb 2005 @ 19:16 ¶