Skip to content

fix: nginx の gzip が HTTP/1.0 のリクエストで効かない問題と、起動時の警告を直す - #1920

Open
mhaya wants to merge 3 commits into
develop_v2.1.0from
fix/nginx-gzip
Open

mhaya wants to merge 3 commits into
develop_v2.1.0from
fix/nginx-gzip

Conversation

@mhaya

@mhaya mhaya commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

変更内容

nginx/weko.conf・nginx/weko-ams.conf・nginx/weko-ams-restricted.conf の gzip 設定と SSL の指定を直す。

  • gzip_http_version を 1.1 → 1.0 にする
  • gzip_types から application/octet-stream を外す
  • gzip_types から text/html を外す(nginx が常に対象にするため重複の警告が出ていた)
  • 非推奨の ssl on; をやめ、listen 443 ssl; にする(起動のたびに警告が出ていた)

目的

  • gzip_http_version 1.1 のため、HTTP/1.0 のリクエストには静的ファイル・アプリの応答ともに圧縮がかからなかった。nginx などのリバースプロキシは既定で HTTP/1.0 で転送するので、前段にプロキシを置く構成では gzip がまったく効かない。
  • application/octet-stream が対象に入っていたため、ファイルのダウンロードまで圧縮していた。圧縮の効かないバイナリに CPU を使ううえ、Content-Length が付かずダウンロードの進捗が出ない。

動作確認

ビルド済みの nginx イメージにこの設定を載せて単体で起動し、上流は同じ uwsgi のソケット接続でダミーのアプリを立てて確認した。

リクエスト 変更前 変更後
HTTP/1.1: HTML / JSON(/api)/ CSS gzip gzip
HTTP/1.0: HTML / JSON(/api)/ CSS 圧縮なし gzip
バイナリ(application/octet-stream) gzip(Content-Length なし) 圧縮なし(Content-Length あり)
  • 3つの設定ファイルすべてで nginx -t が通ることを確認
  • 起動時の警告(text/html の重複、ssl ディレクティブの非推奨)が出なくなることを確認
  • HTTPS で応答し、HTTP(80)は従来どおり HTTPS へ 301 でリダイレクトすることを確認

補足

本番の前段にどのようなプロキシがあるかは環境による。前段が無い構成でブラウザから直接アクセスしている場合は、変更前でも gzip は効いている。

🤖 Generated with Claude Code

Summary by Sourcery

Update all Nginx gzip configurations to support HTTP/1.0 proxy requests while excluding binary downloads from compression.

Bug Fixes:

  • Allow gzip compression for responses forwarded using HTTP/1.0, including requests passing through reverse proxies.
  • Stop compressing application/octet-stream downloads to preserve efficient delivery and Content-Length metadata.

Enhancements:

  • Remove the redundant text/html gzip type from all Nginx configurations to eliminate duplicate configuration warnings.

mhaya and others added 2 commits September 27, 2026 22:19
gzip_http_version 1.1 のため、HTTP/1.0 のリクエストには静的ファイル・
アプリの応答ともに圧縮がかからなかった。nginx などのリバースプロキシは
既定で HTTP/1.0 で転送するので、前段にプロキシを置く構成では gzip が
まったく効かない。gzip_http_version を 1.0 にする。

あわせて gzip_types から text/html を外す(常に対象なので重複の警告が出ていた)。

weko.conf / weko-ams.conf / weko-ams-restricted.conf の3つに同じ変更を入れる。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gzip_types に application/octet-stream が入っており、ファイルのダウンロード
まで圧縮していた。圧縮の効かないバイナリに CPU を使ううえ、Content-Length が
付かなくなりダウンロードの進捗が出ない。3つの設定ファイルから外す。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f3232ee7-98d5-4808-b2d4-c11aa776b0bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

3つの nginx 設定で gzip の適用バージョンを HTTP/1.0 に下げ、前段プロキシ経由の HTML・JSON・CSS も圧縮できるようにするとともに、バイナリの不要な圧縮と text/html の重複指定を解消する。

Sequence diagram for gzip through an HTTP/1.0 proxy

sequenceDiagram
    participant Client
    participant Proxy
    participant Nginx
    participant App
    Client->>Proxy: HTTP/1.1 request
    Proxy->>Nginx: HTTP/1.0 request
    Nginx->>App: uwsgi request
    App-->>Nginx: HTML JSON or CSS response
    Nginx-->>Proxy: gzip response
    Proxy-->>Client: gzip response
Loading

Flow diagram for gzip content-type handling

flowchart LR
    Response["Upstream response"] --> Type{"Content-Type"}
    Type -->|HTML JSON or CSS| Compress["gzip response"]
    Type -->|application/octet-stream| Plain["Uncompressed response\nwith Content-Length"]
Loading

File-Level Changes

Change Details Files
HTTP/1.0 経由のレスポンスでも gzip 圧縮を有効化する。
  • gzip_http_version を 1.1 から 1.0 に変更し、前段プロキシから HTTP/1.0 で転送される構成に対応する。
nginx/weko.conf
nginx/weko-ams.conf
nginx/weko-ams-restricted.conf
圧縮対象の MIME タイプを適正化する。
  • application/octet-stream を除外してバイナリダウンロードの不要な圧縮を防ぐ。
  • nginx が常に gzip 対象とする text/html を除外して重複警告を解消する。
nginx/weko.conf
nginx/weko-ams.conf
nginx/weko-ams-restricted.conf

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

nginx 1.15 以降、ssl ディレクティブは非推奨で、起動のたびに警告が出ていた。
listen 443 ssl に置き換える。3つの設定ファイルに同じ変更を入れる。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mhaya mhaya changed the title fix: nginx の gzip が HTTP/1.0 のリクエストで効かない問題を直す fix: nginx の gzip が HTTP/1.0 のリクエストで効かない問題と、起動時の警告を直す Sep 28, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@github-actions

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

台帳ブランチ: develop_v2.1.0

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: b572c442d v2.0.4-577-gb572c442d (profile=default) endpoints=933 (外部ライブラリ由来 359)
  • 新: 800ccc6b4 v2.0.4-610-g800ccc6b4 (profile=default) endpoints=933 (外部ライブラリ由来 359)

判定: ✅ PASS (FAIL 0 / WARN 0)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 0
IMPL_CHANGED 0
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 0
config 変化 0
コメントアウト認証の増加 0
依存パッケージの版変化 0

変化はありません。


台帳との突き合わせ

スナップショット ↔ インベントリ 突き合わせ

  • リビジョン: 800ccc6b4 v2.0.4-610-g800ccc6b4 経路URI=913
  • 台帳: 行=1053 URI=924

件数のみ。詳細はプライベートリポジトリ側の完全版レポートを参照。

判定: ✅ 一致 (0件)

検出 件数
A. インベントリ未収載(抽出漏れ) 0
B. 実機に無い(未説明) 0
B'. 実機に無い(既知・許容) 11
C. メソッド不一致 0
D. app列の不一致 0
E. endpoint 未収載 0
E'. endpoint が実機に無い(参考) 1

ソース由来の経路検知

ソース由来の経路検知

  • 解析対象: /home/runner/work/weko/weko
検知源 件数
route 286
expose 206
add_url_rule 75
rest_config 28
modelview 23
entry_point 115
計 733

判定: ✅ 全検知が台帳に対応 (0件)

検知源 検知 台帳に対応 未収載 既知・許容
route 286 286 0 0
expose 206 206 0 0
add_url_rule 75 71 0 0
rest_config 28 26 0 2
modelview 23 23 0 0
entry_point 115 115 0 0

add_url_rule(**rule) 形式の config 駆動一括登録が 4 箇所。個々の経路は rest_config 側で検知する。

参考: 静的検知と結びつかなかった台帳行

  • 全体: 170 / 1053 行
  • うち実ファイルを持つ行: 24(pip・framework・ModelView 総称表記を除いた数)

@github-actions

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

台帳ブランチ: develop_v2.1.0

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: b572c442d v2.0.4-577-gb572c442d (profile=default) endpoints=933 (外部ライブラリ由来 359)
  • 新: 8792631c9 v2.0.4-609-g8792631c9 (profile=default) endpoints=933 (外部ライブラリ由来 359)

判定: ✅ PASS (FAIL 0 / WARN 0)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 0
IMPL_CHANGED 0
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 0
config 変化 0
コメントアウト認証の増加 0
依存パッケージの版変化 0

変化はありません。


台帳との突き合わせ

スナップショット ↔ インベントリ 突き合わせ

  • リビジョン: 8792631c9 v2.0.4-609-g8792631c9 経路URI=913
  • 台帳: 行=1053 URI=924

件数のみ。詳細はプライベートリポジトリ側の完全版レポートを参照。

判定: ✅ 一致 (0件)

検出 件数
A. インベントリ未収載(抽出漏れ) 0
B. 実機に無い(未説明) 0
B'. 実機に無い(既知・許容) 11
C. メソッド不一致 0
D. app列の不一致 0
E. endpoint 未収載 0
E'. endpoint が実機に無い(参考) 1

ソース由来の経路検知

ソース由来の経路検知

  • 解析対象: /home/runner/work/weko/weko
検知源 件数
route 286
expose 206
add_url_rule 75
rest_config 28
modelview 23
entry_point 115
計 733

判定: ✅ 全検知が台帳に対応 (0件)

検知源 検知 台帳に対応 未収載 既知・許容
route 286 286 0 0
expose 206 206 0 0
add_url_rule 75 71 0 0
rest_config 28 26 0 2
modelview 23 23 0 0
entry_point 115 115 0 0

add_url_rule(**rule) 形式の config 駆動一括登録が 4 箇所。個々の経路は rest_config 側で検知する。

参考: 静的検知と結びつかなかった台帳行

  • 全体: 170 / 1053 行
  • うち実ファイルを持つ行: 24(pip・framework・ModelView 総称表記を除いた数)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant