Nginx Rate-limiting with a Whitelist

I recently needed to deploy a rate-limiting solution for a site where certain IP addresses would be white-listed and not subjected to the rate limits. Google found me an example in a blog that turned out not to work, though I’ve no idea whether that’s because the example is incomplete or because nginx has changed since it was written. Here’s the solution I eventually came up with.

First, my servers are behind a proxy, so I needed to pull out the originating IP address and to tell nginx that it should never use whatever IP address the connection actually came from:

real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;

Then, using the HttpGeo module, I set up a match list for addresses that should be rate-limited. This sets the variable $limited to 1 (meaning “rate-limit this address”) or 0 (“don’t rate-limit this address”). The default is 1 and I list addresses I don’t want limiting with a zero value. Address ranges are in CIDR notation:

geo $limited {
  default 1;
  10.0.0.0/24 0;
  192.168.42.42/32 0;
}

Now I set another variable, $limit to the IP real IP address of the connection or to the empty string depending on the value of $limited. If the connection is to be rate-limited then the (binary format) IP address will be used; if not, the empty string is used:

map $limited $limit {
  1        $binary_remote_addr;
  0        "";
}

And here’s the limit zone, keyed using the value of $limit:

limit_req_zone $limit zone=limited:10m rate=5r/m;

When $limit is an empty string, the limit will not be applied. Finally, apply the limit in the location stanza:

location / {
    limit_req zone=limited burst=5;
}

In testing this approach appears to work so far. The site in question goes live next week, so I’ll find out then how it copes in the real world.

Posted in Computing | Tagged , | Leave a comment

Another Attempt at a Cygnus Widefield Image

The evening after my previous attempt the sky looked better so I set up again mostly with the same kit (EQ3-2, 450D, 18-55mm lens at 18mm & f/4.5, but this time I used APT to control the camera from the laptop. This made focusing and capture so much easier that I was able to experiment a bit more, tidy up the framing and so on.

This time I took sixty 45 second exposures with ten darks, again stacking them in DSS and tweaking levels and curves in photoshop — another first as I’ve never used Photoshop before.

I’m much happier with this result. There is perhaps a little amp glow showing at the top edge of the image and the stars towards the corners are stretched somewhat because the lens isn’t perfect, but it has so much more impact thanks to the depth of colour and the sheer number of stars visible. I’m pleased enough with it that I’ve resized a version to use as my workstation desktop background 🙂 Here it is:

Posted in Astroimaging, Astronomy | Tagged , , | Leave a comment

My First Widefield Shot

Quite a few “firsts” this week. Makes such a change to have so many nights of clear sky. This night the sky clarity wasn’t great, but I wanted to try a widefield shot and wasn’t too worried about the outcome as long as I got a feel for what was required. I mounted up my unmodified 450D DSLR directly on the EQ3-2 and pointed it towards the constellation of Cygnus. I set up the remote shutter control on the camera to take thirty exposures of 45 seconds each with the kit 18-55mm lens at 18mm and opened as wide as possible at f/4.5.

The thirty exposures together with ten darks were fed into Deep Sky Stacker and I did no further processing. Here’s the result:

I’m not particularly happy with the outcome on this one. I have nicely captured Cygnus, Lyra, Sagitta and Delphinus, but the image really lacks dynamic range. I think the seeing was perhaps actually worse than I realised and that thin high cloud spoilt the image.

Posted in Astroimaging, Astronomy | Tagged , , | Leave a comment

My First SPC900 DSO Images

We’ve just had a full eight days of clear skies and I finally managed to get around to testing my LX-modded SPC900. For the test I used my ST120 on the motorised EQ3-2. This is my first ever attempt at such a thing, so I wasn’t expecting stunning results and I wasn’t disappointed 🙂

First, M13. This first image is 33 exposures of 16 seconds, no darks, captured with SharpCap and stacked in Deep Sky Stacker. There’s no other processing.

And this one is the same, but 55 exposures of 10 seconds.

I can’t really decide which I prefer. The second looks perhaps a little sharper to me. I should perhaps re-stack and do some processing in photoshop, but I’ll come back to that another time.

I also tried capturing M27, the Dumbell, but whilst I ended up with stars close to being over-exposed, the nebula itself was hardly visible. An attempt on M31 similarly in failure and an image massively over-exposed in the core and no data elsewhere. I think more practice is required.

Posted in Astroimaging, Astronomy | Tagged , , | Leave a comment

Paper Planet Models

I found a set of “nets” for icosahedron models of planets and moons recently and made one each of Jupiter with my daughter. They’re quite tricky to make the final joins on — you really need delicate slim fingers, not short dumpy ones such as I am gifted with. Anyhow, here’s how mine turned out:

I downloaded the net as a PDF file from here, but found other paper models here and here. As yet we’ve not tried the last two.

Posted in Astronomy | Tagged , , , | Leave a comment

A Very Late Swarm

Yesterday (22nd July) morning I received a phone call about a bee swarm in a local garden. The swarm was in a holly bush right next to the path to the front door of the house and the owners have young children so not collecting it wasn’t really an option, but I’m now left with a debate over what to do with it. It seems very late to allow them to try to consolidate a new colony in time for the winter, so perhaps I should just dispose of the queen and combine them with another colony, though it was quite a large swarm.

I’m genuinely surprised to see one this late in the year. I imagine they’ve been waiting for some time for an opportunity to leave the parent colony, unable to do so because of the poor weather.

I think I’ll give them a couple of weeks to see if the queen starts laying and then make a judgement about how to combine them.

Posted in Bee-keeping | Tagged , | Leave a comment

Observation Report, 22 July 2012

Having had an excellent night two nights ago I had six Messier objects left to find and set myself the goal of finding M7 this week on the basis that whatever happens in August, between the Moon and the turning of the seasons it will be lost to me until next summer. According to Stellarium it was going to be a really tricky object to find anyhow as it wasn’t going to get much more than four degrees above the horizon at any point.

I had the ST120 out cooling early and took it up to my usual observing site at about 11pm. The sky was clear of cloud, but the seeing was very poor with light pollution from the local town particularly being scattered as much as fifteen degrees up from the horizon. Nonetheless I was on a mission. Clearly the trees have grown an awful lot or the configuration of Stellarium is not quite perfect as its idea of where M7 should be was clearly higher than it could actually be judging from the position Kaus Australis which was the initial point for my star hop and pretty much the same altitude. Kaus Australis was actually below the maximum height of the tree line though I could see it through a gap, so I was feeling fairly negative about my chances of finding M7, but as I panned westwards across the treetops it suddenly popped out in a small gap. I had to wait for the trees as they moved to be able to see it and I’m not actually sure I could see the entire cluster at any one point, but there was nothing else in Stellarium that it could be and based on the few stars and its alignment with the “tail” of Scorpius I’m certain I found it. I still feel somewhat cheated though. Short of taking a scope much further south or finding a hill with a completely clear southern horizon I don’t think there’s much else I can do though.

My “backup plan” for the evening was to find M30, but it was too early and Capriconus was lost in the haze of light to the east anyhow, so I left the scope out and returned to the house to grab some binoculars and spent an hour sitting on the patio watching the sky, looking for meteors and satellites (I saw at least half a dozen of each including what I believe was an Iridium flare, but it disappeared over the house before I could catch up with it). I’ve never had a “good” summer for observing, so I took some time to try to familiarise myself with the orientation of summer constellations and to revisit old friends such as M13. Away from the light pollution around the horizon the sky was much clearer and far more enjoyable to look around.

Around midnight the sky seemed to suddenly get much darker. I wouldn’t be entirely surprised if the local towns have some sort of “switch off” policy at midnight. There certainly seemed to be a marked and immediate change in the darkness of the sky. It was also getting a fair bit colder and when I returned to the scope it was running with dew. Capricornus was visible by this stage though still affected by the haze on the horizon. I found the semi-circle of stars around ζ Capricorni and just swung the scope around a little to the north to find M30 quite easily. In the haze it appeared very dense, somewhat like an unfocused star and no detail was visible, but I have at least found it and Capricornus will be higher in the sky later in the year for me to look at it again.

Although the evening had started off disappointing, spending time with the bins and finding M30 in a clearer sky more than made up for it so I decided to call it a night and returned to the house to dry off the scope. This takes my total of Messier objects found up to 106., leaving just M74, M77, M79 and M83 to find.

As it turned out, I wasn’t done there. I woke up at 3:30am and went to get a drink, passing a window facing north-east. As I looked out of the window I could see Venus chasing Jupiter away from the oncoming dawn. If I’d been a little more aware of what was going on I could also have seen the Pleiades and an ISS pass, but even so I don’t think I have reason to be too unhappy with my nights viewing.

Posted in Astronomy | Tagged , , , | Leave a comment

Observation Report, 20 July 2012

With almost horizon-to-horizon blue skies yesterday evening I gambled on putting out both the 127 Mak on the EQ3-2 so I could polar align it for any solar imaging that I can find time for, and the ST120 with its new-to-me dual-speed Crayford. As twilight fell the occasional cloud popped up, but nothing that bothered me too much. Things were still looking good. Sadly the story was not the same by 11pm as a fair bit of cloud had built up and was speeding its way across the sky, greatly enlarging the light dome of Taunton and blotting out much from the north round to the south-east. Nonetheless, my last night out was 19th June, and 15th May before that. I’d probably sit outside under a blanket with holes poked it in by now, so I was determined to make the best of it.

M72 and M73 were my first two targets, but Capricornus was completely covered by cloud so I went back to look for M24. I just couldn’t find M24 last time I was out, but I’ve since seen photographic images showing it quite clearly which gave me a much better idea of what I was looking for. Having spent a little time on a detour to M22 and the Omega and Eagle nebulae I found what is clearly a much more dense area of blue-white stars in the right place for M24. Now i’ve seen it and understand what it is I’m not in the least surprised I couldn’t find it last time. My expectations were all wrong and I probably looked straight at it without realising what I was looking at.

The main Sagittarius asterism was scooting along the tree tops, so I decided to try to find the three Messier objects along the bottom edge. All three were fairly simple star hops from Kaus Australis, but being so low on the horizon they were also fairly unrewarding to view. More aperture and a more southerly latitude is required for these one day I think. M54 was a landmark for me though, being my 100th Messier object.

Around half past midnight I looked up at Ursa Minor to get an estimate of NELM for the night (getting up towards 5.5) and as I was counting stars a beautiful meteor shot southwards straight through both Ursa Minor and Major leaving a trail of sparkling debris behind it covering about thirty to forty degrees of sky (measured using my hands) before winking out. It must be the prettiest meteor I’ve ever seen. Such a shame it lasted no more than a heartbeat.

By this time the cloud over Capricornus was clearing and I could see the “tail” stars, so I moved on to find M75. Another that needs more aperture, I think, but hopefully it should benefit from being a little higher in the sky later in the year. I’m not at all sure the remaining cloud wasn’t washing out the view a little too, as M72 and M73 were very much the same. I fancy I did at one point glimpse the Saturn Nebula using averted vision, but I really can’t be sure.

My final “new” Messier for the night was M55, still low on the horizon and not the most straightforward of hops from τ Sagittarii as few stars were visible at such low altitude. I identified where I thought it ought to be and was greeted with a mushy grey view of, well, nothing, really. For just a fleeting few seconds the sky cleared and I saw what might well be a fairly impressive globular cluster under better conditions, but obviously last night was not to be the night. Another for the “more aperture, less latitude” list.

As I packed up I spent a bit of time just looking at the sky as a whole. Much of the cloud had cleared and the view of the Milky Way was outstanding, clearly running all the way from Scorpius over to the northern side of Cassiopeia. As I walked down the garden path I was so distracted by the fact that I could see M31 with the naked eye that I almost impaled myself on the washing line.

Clearly this was too good to miss, so I packed up the scope, found the bins and a beer and sat outside just scooting around the sky picking out stars, watching satellites and chasing meteors with the 10x50s. At one point I saw an astonishingly bright flash in the Milky Way near Sagitta which travelled north as it dimmed. I assume it was an Iridium flare, but I’ve not yet checked. Having never seen it before I also found the Coathanger entirely by chance, and whilst looking away and finding it again just to prove I could realised that it is also a naked eye object here.

By 2am I decided that If I didn’t want to be a complete waste of space this morning I’d better call it a night and did so very contentedly.

Posted in Astronomy | Tagged , | Leave a comment

Dovetail Adaptor for Old EQ3-2 Mounts

My EQ3-2 is one of the older models that has fittings for scope rings, but doesn’t have any form of dovetail clamp. The new models have both. I prefer to use dovetails as it makes swapping scopes around between mounts easier, so I decided to modify my mount to add a suitable saddle. I’ve seen this done by mounting a saddle on a section of dovetail that is then bolted to the mount using the holes for the rings, but I wanted something with a little more lateral stability.

I bought a new saddle from Sky’s the Limit and after some hunting around discovered that it’s possible to buy small sheets of aluminium on ebay for very little money. I bought some 5mm sheet and cut out a piece that would support the entire base of the saddle as well as resting on the sides of the mount head. The plate extends out far enough to reach the holes for mounting scope rings. I drilled out matching holes in the plate and tapped them to accept an M6 thread. When fitted to the mount the bolts then hold the plate tight to the top of the mount without it being able to rock or twist.

Four more holes tapped to M6 take the screws that hold the saddle to the plate. Tapping M6 holes squarely in 5mm plate is tricky. I discovered the way to do it is to put the tap into the chuck of a pillar drill with the plate clamped to the table and then turn the chuck by hand. This keeps the tap square to the face of the plate. Doubtless there’s some clever way to do this, but it worked for me.

Here’s what it looks like when assembled:

I’ve not had a chance to try it out properly yet as it’s rained for the last three months. Hopefully things will change some time soon. If they don’t change soon though I’ll be making a similar adaptor for my AZ3 to take a dovetail.

Posted in Astro Equipment, Astronomy, Projects | Tagged | Leave a comment

Solar PV Generation Update, July 2012

Unless you have some strange rain fetish, June has been an awful month weather-wise. There’s been hardly a single day here when it didn’t rain and even when rain wasn’t falling the sky has been mostly cloudy. According to the Met Office June was the wettest month on record (for more than 100 years) with rainfall across the UK averaging perhaps 10% more than the previous worst year. There’s little sign of a let-up in July either thanks to the northern polar jet stream just sitting stationary across the UK for the foreseeable future.

So, the numbers. Generation for June was 327kWh, worse than any other month since February. That brings our total generation to 2507kWh since installation, bringing in about £1130 in FIT payments and saving us up to £375 in electricity not purchased from the grid.

Such poor performance has pushed our predicted output for the year even further back to around 3370kWh for the year. Unless the sun goes out I can’t see how July can really be that much worse.

Posted in Environment, Projects | Tagged , , | Leave a comment