My Opera is closing 3rd of March

iTunes Remote for OperaDS

A web based remote for iTunes, built for Opera for the Nintendo DS

Subscribe to RSS feed

Block Apache to outsiders

, , ,

Though I'm sure its rarely necessary, I'm going to post this bit of mod_rewrite magic that took me quite a while to sort out (this is the only syntax that would work). What it does is bounce (because I like being a smart-ass) any request made to Apache unless it is made from the local network (subnet/intranet access only). I figure there has to be a few Mac users sharing their ethernet connection over AirPort. Though I'm not certain that can be done with PPoE...


This has not been tested on a server accessible to outsiders, but I'll do that before releasing Apache instructions in the final package.

Open httpd.conf (in the Terminal, type sudo pico /etc/httpd/httpd.conf, press Return then enter you password at the prompt and press Return).

This section looks like a great place to put it. Scroll down until you find it.
# First, we configure the "default" to be a very restrictive set of
# permissions.
#

After those lines, paste this:
###################################################
###     Protect server from outside traffic     ###
###################################################

RewriteEngine on      
RewriteCond %{REMOTE_ADDR} !^10\.
RewriteRule ^/(.*) http://%{REMOTE_ADDR}/ [L,E=nolog:1]

###################################################

IMPORTANT: If your subnet IP prefix begins with anything other than 10. (one zero dot) be sure to change the RewriteCond line to reflect that.

Press Ctrl-x, then y, then Return and restart Apache.