cgi "**.cgi|/cgi-bin/*" {
    enabled = true
    setenv  = { "MERECAT_TEST_VAR=hello_setenv" }
}

ssi "**.shtml" {
    enabled  = true
    cgi-path = "cgi-bin/ssi"
}

php "**.php*" {
    enabled  = true
}

server hej {
    port = 8086

    # Forward /proxy/** transparently (original URI preserved)
    proxy-pass "/proxy/**" {
        backend = "http://localhost:9090"
    }

    # Forward /v2proxy/** with path prefix stripping
    # GET /v2proxy/foo -> GET /v2/foo on the backend
    proxy-pass "/v2proxy/**" {
        backend = "http://localhost:9090/v2"
    }

    # Forward /strip/** stripping the prefix only (trailing slash, no sub-path)
    # GET /strip/hello -> GET /hello on the backend
    proxy-pass "/strip/**" {
        backend = "http://localhost:9090/"
    }

    # Forward /redir/** and rewrite Location: headers from backend
    # Backend returns: Location: http://localhost:9090/redir/target
    # Merecat rewrites:          Location: http://localhost/redir/target
    proxy-pass "/redir/**" {
        backend        = "http://localhost:9090"
        proxy-redirect = "http://localhost:9090 http://localhost:8086"
    }

    # Backend that accepts and closes without responding (proxy.sh pass 10)
    proxy-pass "/dead/**" {
        backend = "http://localhost:9091"
    }

    # Backend that resets the connection on first write (proxy.sh pass 12)
    proxy-pass "/rst/**" {
        backend = "http://localhost:9092"
    }

    # IPv6-only backend, bracketed literal (proxy.sh pass 14)
    proxy-pass "/v6/**" {
        backend = "http://[::1]:9093"
    }
}

server nej {
    port = 8080
    # If location is requested, replace with path
    location "/.secret/path/**" {
    	     path = "/img"
    }
    redirect "/**" {
    	     code = 301
    	     location = "http://$host:8086$request_uri$args"
    }
}
