I'm concerned at the amount of people saying here that you should have allowed to be rear ended. Truth be told, you shouldn't have been in the position for him to rear end you with lights coming up; you should have been slowing down far in advance to hitting the lights if he was that close to your 6 (in the same way you should deal with tailgaiters on the motorway), the greater the distance you slow down over, the less likely a collision is, giving you more than enough space to slow him to a safe stop.
Not having a snipe on my high horse, avoiding accidents from behind is something they don't teach you for your test (but bloody well should) and it's something you don't pick up until you have experience, so it's easy to see why you might have paniced and jumped the light. But ultimately it takes two to have an accident, and part of avoiding one can be to influence those around you.
just one of those things, it's your fault at the end of the day, but imo you were just unlucky. Many new drivers make the same mistakes and just dont get caught. enjoy your last month or so of driving for a while and remember it's not the end of the world, you can re-test and start over..