Getting started
Basics
Domains & Origins
Performance

Configuration
Basics
Conditions
Dictionaries
Domains & Origins
Request settings
Cache settings
Headers
Responses
Performance
Custom VCL
Image optimization
Video

Security
Access Control Lists
Monitoring and testing
Securing communications
Security measures
TLS
Web Application Firewall

Integrations
Logging endpoints
Non-Fastly services

Diagnostics
Streaming logs
Debugging techniques
Common errors

Account info
Account management
Billing
User access and control

Reference

    Tracking your origin's name, IP, and port

      Last updated October 30, 2018

    Being able to track information related to your origin can be helpful in troubleshooting errors and making sure requests are processed as expected. Fastly provides three VCL variables that allow you to see and track origin information:

    You can create VCL Snippets that use these variables to capture information about an origin and then set up remote log streaming to save that information.

    Retrieve the origin information

    Create a regular VCL Snippet to retrieve the origin information:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the VCL snippets link. The VCL snippets page appears.
    5. Click Create snippet. The Create a VCL snippet page appears.
    6. In the Name field, type an appropriate name (for example, Retrieve-Origin-Information).
    7. From the Type controls, select within subroutine. The Select subroutine menu appears.
    8. From the Select subroutine menu, select fetch (vcl_fetch).
    9. In the VCL field, add the following VCL logic:

      1
      2
      3
      
      # save the variables for access in deliver
      set beresp.http.Your-Backend-Name = beresp.backend.name;
      set beresp.http.Your-Backend-IP-Port = beresp.backend.ip ":" beresp.backend.port;
      
    10. Click Create to create the snippet.

    Change the response header to a request header

    Create another regular VCL Snippet that changes the response header to a request header before logging the information:

    1. Click the VCL snippets link. The VCL snippets page appears.
    2. Click Create snippet. The Create a VCL snippet page appears.
    3. In the Name field, type an appropriate name (for example, Remove-Origin-Information).
    4. From the Type controls, select within subroutine. The Select subroutine menu appears.
    5. From the Select subroutine menu, select deliver (vcl_deliver).
    6. In the VCL field, add the following VCL logic:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      
       if (fastly_info.state ~ "(MISS|PASS)") {
         # only on a miss or pass
         # save the responses back to req.request because
         # request headers are not sent back to the client
         set req.http.Your-Backend-Name = resp.http.Your-Backend-Name;
         set req.http.Your-Backend-IP-Port = resp.http.Your-Backend-IP-Port;
         }
      
       # remove the identifying information from the response
       unset resp.http.Your-Backend-Name;
       unset resp.http.Your-Backend-IP-Port;
      
    7. Click Create to create the snippet.

    Set up remote log streaming

    Once your snippets are created, you can set up remote log streaming for tracking purposes. Do this by adding req.http.Header-Name to the Log format field in the logging endpoint you configured in the remote log streaming guide. Using the example above, you would add req.http.Your-Backend-Name and req.http.Your-Backend-IP-Port. Once you've reviewed the changes you've made, click the Activate button to deploy these configuration changes for your service.

    Back to Top