How to use a different Host header for a non-S3 backend within the same service


#1

To override the Host header set to Amazon S3 for a single backend, you would normally use the hostname of your S3 bucket when you specify the default host for a service. To use a different Host header for a non-S3 backend within the same service, however, you should perform the Host overwrite using a new Header in the Default Settings and then you should specify a new request condition to set that header appropriately.

  1. Log in to the Fastly application and click the configure tab to access the control panel.

  2. Select the appropriate service from the Service menu.

  3. Click the blue Configure button to the right of the service name.

  4. Click the Content pane from the list on the left.

  5. In the Headers area, click the New button to create a new header. The New Header window appears.

  6. Fill out the New Header window as follows:

  • In the Name field, type S3_Host_Rewrite.
  • From the Type menu select Request and from the Action menu, select Set.
  • In the Destination field, type http.Host.
  • In the Source field, type “.s3.amazonaws.com”.
  • From the Ignore if Set menu, select No.
  • In the Priority field, type 10.
  1. Click the Create button. A new header appears in the Headers area of the Content section.

  2. Click the gear icon next to the name of the header you just created and select Conditions. The Choose Conditions window appears.

  3. Click the New button to create a new condition. The New Condition window appears.

  4. Fill out the New Condition window as follows:

  • In the Name field, type S3_Host_Rewrite_Condition.
  • In the Apply if field type req.http.Host == “images.fee.bar”.
  1. Click Activate to deploy your changes.