Use IIS as a Reverse Proxy for Octopus Deploy

Last updated

There are scenarios in which you may be required to run Octopus Deploy behind a reverse proxy, such as compliance with specific organization standards, or a need to add custom HTTP headers. This document outlines how to use Microsoft's Internet Information Services (IIS) as that reverse proxy, using URL Rewrite and Application Request Routing (ARR).

This example assumes:

Our starting configuration:

At the end of this walkthrough, you should be able to:

  • Communicate with Octopus Deploy over a secure connection.
  • Set and verify a custom HTTP header with IIS.

Install URLRewrite and ARR

URLRewrite and Application Request Routing are provided by the Microsoft Web Platform Installer. After installing the Web Platform Installer, search for "URL Rewrite" and "Application Request Routing", and install.

Alternatively, use the following PowerShell snippet:

$downloadUrl = "http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi"
$downloadtarget = ([uri]$downloadUrl).segments | select -last 1
Invoke-WebRequest $downloadUrl -OutFile $env:tmp\$downloadtarget
Start-Process $env:tmp\$downloadtarget '/qn' -PassThru | Wait-Process
Set-Location ($env:ProgramFiles + "\Microsoft\Web Platform Installer")
.\WebpiCmd.exe /Install /Products:'UrlRewrite2,ARRv3_0' /AcceptEULA /Log:$env:tmp\WebpiCmd.log

Configure SSL on Default Web Site

  1. Open the IIS Management Console (inetmgr.exe)

  2. Navigate to the Default Web Site

  3. In the action pane, click on "Bindings"

  4. Click "Add"

  5. Select "https"

  6. A dropdown box will appear with your installed certificates displayed

  7. Select your installed certificate. If you don't see your certificate listed, refer back to this MSDN Article

  8. Optional: Fill in your correct IP address and/or hostname, and click "OK"

  9. Optional: Remove the HTTP (non-SSL) binding - this is a recommended security practice

Verify SSL is correctly configured

In a web browser, navigate to https://servername (note the 's').

You should see the IIS default page displayed in your browser.

IIS Default Page

Configure URLRewrite

After installing URLRewrite and ARR, you may need to restart IIS and/or the IIS Management Console to ensure that the URLRewrite icon appears correctly

Open the IIS Management Console (inetmgr.exe).

Navigate to the Default Web Site.

Click on the URLRewrite icon to bring up the URLRewrite interface.

In the action pane, click on "Add Rule(s)".

Under "Select a Rule Template", choose "Reverse Proxy".

Adding a Reverse Proxy Rule in URL Rewrite.

If you have never enabled reverse proxy functionality before, you'll be prompted to enable it.

In the "Add Reverse Proxy Rules" dialog, specify the URL of your backend Octopus Server in "Inbound Rules". In our example, this is servername:8080.

Select "Enable SSL offloading".

Cick OK.

Configuring a Reverse Proxy Rule

There is no need to specify outbound rules, as the Octopus Portal always uses relative links.

Click OK and close down all dialogs.

You should now be able to navigate to https://servername/ in your browser and log in to Octopus Deploy.

Polling Tentacles are not supported with this scenario
Polling Tentacles communicate with the Octopus Server over an end-to-end encrypted channel. This solution does not currently support polling Tentacles.

Example: Add a Custom HTTP Header in IIS

Open the IIS Management Console (inetmgr.exe).

Navigate to the Default Web Site.

In the Main window, navigate to "HTTP Response Headers".

In the action pane, click "add".

In the dialog, enter the following.

  • Name: x-octopus-servedby
  • Value: IIS

Click OK.

Verify the Custom HTTP Header

Open a PowerShell prompt.

Type the following command (replacing 'servername' as appropriate):

Invoke-WebRequest https://servername | select -expand Headers

You should see your x-octopus-servedby header listed in the returned headers.