3

I have a subdomain with service I am going to kill.

I'd like to use 410 to mark it as such.

Is there a way to do that with lighttpd without resolving to mod_magnet and lua scripts?

Almad
  • 151
  • 7
  • 1
    mod_magnet is the right solution for this, and you didn't give a reason why you don't want to use it. – Stefan Jan 07 '13 at 18:38
  • 1
    @Stefan Well, from docs: "While the lua language the mod_magnet uses is very powerful, mod_magnet is not meant to be a general replacement for your regular scripting environment. This is because mod_magnet is executed in the core of Lighty and EVERY long-running operation is blocking ALL connections in the server. You are warned." . But true, I have not tested this so I am probably worried needlessly. – Almad Jan 08 '13 at 11:13
  • 1
    Ah yes. Well, returning 410 as status code is neither a long running nor a blocking operation, so mod_magnet is fine. long running would be calculating stuff, like compression or prime number generators, and blocking operations refer to local file io or (usually worse) network io (databases, ...). – Stefan Jan 08 '13 at 14:07

1 Answers1

3

Set the document root to an otherwise empty directory, and use a dynamic error handler to send a 410 response.

Example:

$HTTP["host"] == "gone.example.com" {
  server.document-root = "/var/www/gone"
  server.error-handler-404 = "/gone.php"
}

Where /var/www/gone/gone.php contains something like the following:

<?php
header("HTTP/1.1 410 Gone");
header("Status: 410 Gone");
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • I don't have any dynamic handlers on this server, but otherwise it's fine hack. – Almad Jan 07 '13 at 12:11
  • No PHP, perl, Rails, anything else? It doesn't have to be PHP... – Michael Hampton Jan 07 '13 at 13:57
  • Nope, it delegates backends to other servers through fcgi. – Almad Jan 07 '13 at 15:52
  • 2
    1. I recommend using url.rewrite-if-not-file instead of server.error-handler-404, 2. if you don't want mod_magnet it looks like you're searching for something "small" - a fastcgi/php backend is certainly not better. – Stefan Jan 07 '13 at 18:42