Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save asasuou/bb0e3c6dd7b74eb708344d7733f1c1cf to your computer and use it in GitHub Desktop.

Select an option

Save asasuou/bb0e3c6dd7b74eb708344d7733f1c1cf to your computer and use it in GitHub Desktop.

Revisions

  1. @ebouchut ebouchut revised this gist Apr 25, 2019. No changes.
  2. @ebouchut ebouchut created this gist Feb 29, 2012.
    43 changes: 43 additions & 0 deletions LighttpdReverseProxyURLRewriting
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #server.modules += ( "mod_rewrite")

    # Workaround to have a working reverse-proxy that matches an URL does URL rewriting in Ligghtpd.
    #
    # Ligtthpd 1.4.28 cannot perform both matching and URL rewriting at the same time.
    # Therefore we need to define 2 proxies, one does the matching and bounce the request
    # to the other one, in charge of rewriting the URL before proxying the request to the target server.
    #
    # More about this here:
    # http://redmine.lighttpd.net/issues/164#note-9


    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # $HTTP["url"] =~ /servername/path
    # => 127.0.0.1:82 (rewrite : remove "/servername")
    # => servername:80/path
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # Matching Proxy
    #
    $HTTP["url"] =~ "(^/servername/)" {
    proxy.server = ( "" => (
    "servername:80" => # name
    ( "host" => "127.0.0.1",
    "port" => 82
    )
    )
    )
    }


    # URL Rewriting Proxy
    #
    $SERVER["socket"] == ":82" {
    url.rewrite-once = ( "^/servername/(.*)$" => "/$1" )
    proxy.server = ( "" => (
    "servername:82" => # name
    ( "host" => "10.0.0.1", # Set the IP address of servername
    "port" => 80
    )
    )
    )
    }