---
description: Gateways, Tunnels, and Relays
---

# ch08: Integration Points

![8.网关、隧道和中继](https://tva1.sinaimg.cn/large/007S8ZIlly1gghcg1eq5gj30ut0u0dl2.jpg)

## 1. Gateways

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi75f9sgnj314s0hsjw4.jpg)

Three Types of Gateway:

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi78tgwhjj31500sa0yc.jpg)

Gateways are described by their client- and server-side protocols, separated by a slash:

```
<client-protocol>/<server-protocol>
```

* _Server-side gateways_ speak HTTP with clients and a foreign protocol with servers (HTTP/\*).
* _Client-side gateways_ speak foreign protocols with clients and HTTP with servers (\*/HTTP).

## 2. Protocol Gateways

### 2.1 HTTP/\*: Server-Side Web Gateways

Convert client-side HTTP requests into a foreign protocol, as the requests travel inbound to the origin server.

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi7gi9layj314m0hqq7h.jpg)

### 2.2 HTTP/HTTPS: Server-Side Security Gateways

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi7h54w6uj314q0cqgpw.jpg)

### 2.3 HTTPS/HTTP: Client-Side Security Accelerator Gateways

HTTPS/HTTP gateways sit in front of the web server, usually as an invisible intercepting gateway or a reverse proxy.

They receive secure HTTPS traffic, decrypt the secure traffic, and make normal HTTP requests to the web server.

These gateways often include special decryption hardware to decrypt secure traffic much more efficiently than the origin server.

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi7kptw7tj314k0fi430.jpg)

## 3. Resource Gateways

An application server:

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi7nilch1j314w0keqa5.jpg)

### 3.1 Common Gateway Interface (CGI)

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi7olexd4j314s0gsn0d.jpg)

## 4. Tunnels

Web tunnels, enable access to applications that speak non-HTTP protocols through HTTP applications.

### 4.1 Establishing HTTP Tunnels with CONNECT

Web tunnels are established using HTTP's CONNECT method.

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi7v1ooj7j30y10u07e0.jpg)

**CONNECT requests:**

```
CONNECT home.netscape.com:443 HTTP/1.0
User-agent: Mozilla/4.0
```

**CONNECT responses:**

```
HTTP/1.0 200 Connection Established
Proxy-agent: Netscape-Proxy/1.1
```

### 4.2 SSL Tunneling

Web tunnels were first developed to carry encrypted SSL traffic through firewalls.

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi7yw82y6j314q0qgn4b.jpg)

To allow SSL traffic to flow through existing proxy firewalls, a tunneling feature was added to HTTP, in which raw, encrypted data is placed inside HTTP messages and sent through normal HTTP channels.

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi80asw0jj31410u0grd.jpg)

### 4.3 Tunnel Authentication

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi81tmwq7j30y70u011y.jpg)

## 5. Relays

HTTP relays are simple HTTP proxies that do not fully adhere to the HTTP specifications.

Relays process enough HTTP to establish connections, then blindly forward bytes.

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggi839l449j314k0ju444.jpg)
