Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/ctx.md
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,7 @@ resources while the server prepares the full response.
:::caution
This feature requires HTTP/2 or newer. Some legacy HTTP/1.1 clients may not
Comment thread
akilesh1706 marked this conversation as resolved.
Outdated
Comment thread
akilesh1706 marked this conversation as resolved.
Outdated
Early Hints (`103` responses) are supported in HTTP/2 and newer. Older HTTP/1.1 clients may ignore these interim responses or misbehave when receiving them.
See [Enabling HTTP/2](../guide/enabling-http2.md) for instructions on how to use a reverse proxy (e.g. Nginx or Traefik) to enable HTTP/2 support.
:::

```go title="Signature"
Expand Down
72 changes: 72 additions & 0 deletions docs/guide/enabling-http2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
id: enabling-http2
title: Enabling HTTP/2
description: >-
Learn how to enable HTTP/2 (and optionally HTTP/3) in Fiber using reverse
proxies like Nginx or Traefik. Required for features such as SendEarlyHints
and other modern HTTP capabilities.
Comment thread
gaby marked this conversation as resolved.
Outdated
sidebar_position: 4
---

## Enabling HTTP/2

Check failure on line 11 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Headings should be surrounded by blank lines

docs/guide/enabling-http2.md:11 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## Enabling HTTP/2"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md022.md
Some features in Fiber, such as SendEarlyHints, require HTTP/2 or newer.
If your app is served directly over HTTP/1.1, certain features may be ignored or not function as expected.

To enable HTTP/2 in production, you can run Fiber behind a reverse proxy that upgrades connections.
Popular choices include Nginx and Traefik.

Nginx Example
```nginx title="Example"

Check failure on line 19 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Fenced code blocks should be surrounded by blank lines

docs/guide/enabling-http2.md:19 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```nginx title="Example""] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
Comment thread
gaby marked this conversation as resolved.
Outdated
server {
listen 443 ssl http2;
server_name example.com;

ssl_certificate /etc/ssl/certs/example.crt;
ssl_certificate_key /etc/ssl/private/example.key;

location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
}
Comment on lines +36 to +37

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This Nginx configuration is missing important headers for a reverse proxy setup. To ensure the backend Fiber application can correctly identify the client's IP address and the protocol used, you should add X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto headers. This is crucial for logging, security, and generating correct URLs.

Suggested change
proxy_set_header Host $host;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

}
```

Check failure on line 34 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Fenced code blocks should be surrounded by blank lines

docs/guide/enabling-http2.md:34 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
This configuration enables HTTP/2 with TLS and proxies requests to your Fiber app on port 3000.

Traefik Example
```yaml title="Example"

Check failure on line 38 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Fenced code blocks should be surrounded by blank lines

docs/guide/enabling-http2.md:38 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```yaml title="Example""] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
entryPoints:
websecure:
address: ":443"

http:
routers:
app:
rule: "Host(`example.com`)"
entryPoints:
- websecure
service: app
tls: {}

services:
app:
loadBalancer:
servers:
- url: "http://127.0.0.1:3000"
```

Check failure on line 57 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Fenced code blocks should be surrounded by blank lines

docs/guide/enabling-http2.md:57 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
With this configuration, Traefik terminates TLS and serves your app over HTTP/2.
Comment thread
gaby marked this conversation as resolved.
Outdated

## HTTP/3 (QUIC) Support

Check failure on line 60 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Headings should be surrounded by blank lines

docs/guide/enabling-http2.md:60 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## HTTP/3 (QUIC) Support"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md022.md
While Early Hints (103 responses) are officially part of HTTP/2 and newer, many reverse proxies also support HTTP/3 (QUIC).

Nginx: Requires a recent build with QUIC/HTTP3 patches.
Traefik: Supports HTTP/3 via its entryPoint configuration.

Enabling HTTP/3 is optional but can provide lower latency and improved performance for clients that support it. If you enable HTTP/3, your Early Hints responses will still work as expected.

For more details, see the official documentation:

- [Nginx HTTP/2 Module](https://nginx.org/en/docs/http/ngx_http_v2_module.html)

Check failure on line 70 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Trailing spaces

docs/guide/enabling-http2.md:70:80 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
- [Nginx QUIC / HTTP/3](https://nginx.org/en/docs/quic.html)

Check failure on line 71 in docs/guide/enabling-http2.md

View workflow job for this annotation

GitHub Actions / markdownlint

Trailing spaces

docs/guide/enabling-http2.md:71:61 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
Comment thread
gaby marked this conversation as resolved.
Outdated
- [Traefik HTTP/3](https://doc.traefik.io/traefik/reference/install-configuration/entrypoints/#http3)
Loading