Room for another reverse-proxy?

Friday, 17 September 2010

Like many people I use Apache's mod_proxy to proxy from *:80 to a bunch of servers running upon

(I've mentioned this too often; but in short I have a bunch of sites all running with thttpd under their own UID).

Why do I use apache soley as a reverse proxy, instead of pound, varnish, nginx, or lighttpd? After all it is pretty heavy-weight. Well the answer to that is that I have a bunch of mod_rewrite rules.

So I'm wondering, could I drop apache if I were to hack together a simple network proxy that would listen upon port 80, reading requests, and directing them to local servers? The answer to that is plainly "yes". There are many reverse-proxies around and writing them isn't hard.

So what would be the point? Imagine a reverse-proxy that understood mod_rewrite rules. That would rock.

In short we'd have to define three things:

  • Matching vhost name.
  • Destination to proxy to.
  • (Optionally) the mod_rewrite rules

Given something like this:


host or host
   #redirect traffic here
   proxy_to 1011

   RewriteRule /about /cgi-bin/index.cgi

When the proxy received an incoming request to it would actually send the request /cgi-bin/index.cgi to the host

That seems neither too complex nor too impossible.

The hard part would be emulating mod_rewrite 100%. Especially chained requests. I would be willing to write the trivial version, but I suspect the full emulation would be a job of diminishing returns. Am I right?

ObSubject: You crossed the line first, sir. - "The Dark Knight"



Comments On This Entry

[gravitar] Dan Carley

Submitted at 18:21:45 on 17 september 2010

Nginx's rewrite module is pretty powerful.

No need to reinvent the wheel :)

[author] Steve Kemp

Submitted at 18:24:43 on 17 september 2010

The problem is that Apache's mod_rewrite is the defacto standard for such things.

Anything and everything from wordpress, to phpbb, and mediawiki includes such rules. Nothing else, except for Apache/Apache 2.x, understands them.

Yes other servers have similar features. But no that doesn't make it necessarily easy to convert.

[gravitar] Andrew

Submitted at 19:44:45 on 17 september 2010

As mentioned nginx is pretty powerful as reverse-proxy(i think it's a defacto standard right now). From my experience with migration from apache to nginx rewrite rules almost the same(little difference in keywords) won't take much time to fix and pretty straight-forward.

[gravitar] Np237

Submitted at 09:46:53 on 18 september 2010

I really have the feeling you are reinventing the wheel. Things like nginx and lighttpd are perfect for this kind of use, and they have powerful rewrite engines.

[author] Steve Kemp

Submitted at 10:28:20 on 18 september 2010

I think perhaps I'm not making my point clearly enough:

  • Yes there are other things working as reverse-proxies.
  • Their rules are different enough that mass-conversion is a pain.

I think you've all convinced me that either my suggestion of a mod_rewrite syntax-port, rather than anything else, is not something that seems useful to others.

For the moment I'll keep Apache2 and I will example using nginx instead in the near future.

I do personally think that mod_rewrite is the defacto standard and having to reinvent the wheel by porting such rules to different servers is a bigger waste of time than having a proxy.

That said I can understand the argument :)

[gravitar] Robert

Submitted at 11:33:36 on 18 september 2010

(If I were ignoring your mod_rewrite desires I would of course just say "use haproxy", but...)

If you want to get 100% compatibility with mod_rewrite, you might be best to just rip the heart out of mod_rewrite itself into an abstract url-rewriting library. Who knows, the mod_rewrite maintainers might be interested in factoring out the central rewrite engine.

[gravitar] XANi

Submitted at 13:00:53 on 18 september 2010

Tbh. I would rather have some kind of converter that converts from mod_rewrite format to lighttpd/nginx rules

[gravitar] poisonbit

Submitted at 16:35:07 on 18 september 2010

I think it is a marvelous idea.

Said that, if the idea is to be fully compatible, maybe that your invent needs to XSload mod_rewrite.c :)

I wish that light reverse proxy with full apache > 1.3 rewrite compatibility.

Load existing mapfiles and existing apache2 prg's, could be a plus.


[gravitar] Nux

Submitted at 17:30:55 on 18 september 2010

To be honest, having a reverse proxy capable of Apache rewrite rules would be pretty sweet.
Porting/implementing something like this in Nginx would be AWESOME (yes, I know that it already has powerful rewrite rules) but it also could take a long time and perhaps there is a reason nobody tried/succeeded to do it yet.

I for one could enjoy very much a small/minimalistic perl daemon can understand Apache rewrite rules. I'm sure such a project wouldn't go unnoticed.


Comments are closed on posts which are more than ten days old.

Recent Posts

Recent Tags