Changing the URL that gets logged?



  • Dara Roberts

    Hi JD, 

    Thanks for posting this! 

    Have you tried storing the URL as a value?

    Doing something like this to capture the original url:

    if (req.restarts == 0) {
    set req.http.orig-url = req.url;

    Then using that value in the flow. 

    The flow would look something like this:

    1. Original request comes in
    2. URL for request is stored in a value. (see above)
    3. Request gets sent to origin.
    4. 404 is returned from origin.
    5. req.url is rewritten to be like req.url = "/my404page"
    6. restart; is called.
    7. The request, now with req.url = "/my404page", goes to the origin, appropriate content is returned, and the content is served to the user with status 404.
    8. Previously set value is called 
    9. vcl_log is called and req.http.orig-url is logged.

    Let us know if you have any questions!


    Comment actions Permalink
  • JD Weiner

    Thank you, Dara, this looks really useful!  I've tested it in one of our services, and it looks like it does exactly what I need; the only other change that has to be made is to explicitly log "req.http.orig-url" instead of the default req.url.

    Comment actions Permalink

Please sign in to leave a comment.