[PR #1397] Fix: Move http2 directive inside listen to resolve “unknown directive http2” error #5706

Closed
opened 2026-03-01 15:42:21 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/0xJacky/nginx-ui/pull/1397

State: closed
Merged: No


Summary

This PR updates the NGINX configuration to correctly enable HTTP/2 by moving the http2 directive inside the listen statement.
Previously, using http2 as a standalone directive caused:

nginx: [emerg] unknown directive "http2" in /etc/nginx/sites-enabled/default:XX

Problem

The original configuration:

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;

    ...
}

Using http2 as a separate directive is not supported by NGINX.
This breaks the reverse proxy setup, especially for services that require WebSocket or HTTP/2.

Solution

The http2 directive is now placed correctly inside the listen statement:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ...
}

This ensures proper HTTP/2 support and removes the startup error.

**Original Pull Request:** https://github.com/0xJacky/nginx-ui/pull/1397 **State:** closed **Merged:** No --- # Summary This PR updates the NGINX configuration to correctly enable HTTP/2 by moving the http2 directive inside the listen statement. Previously, using http2 as a standalone directive caused: ``` nginx: [emerg] unknown directive "http2" in /etc/nginx/sites-enabled/default:XX ``` # Problem The original configuration: ``` server { listen 443 ssl; listen [::]:443 ssl; http2 on; ... } ``` Using http2 as a separate directive is **not supported by NGINX**. This breaks the reverse proxy setup, especially for services that require WebSocket or HTTP/2. # Solution The http2 directive is now placed correctly inside the listen statement: ``` server { listen 443 ssl http2; listen [::]:443 ssl http2; ... } ``` This ensures proper HTTP/2 support and removes the startup error.
kerem 2026-03-01 15:42:21 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#5706
No description provided.