LoginSignup
9
8

More than 5 years have passed since last update.

Consul Web UIで画面が表示されない時の対処法

Posted at

tl:dr

「net::ERR_CONTENT_LENGTH_MISMATCH」 が出たら proxy_max_temp_file_size 0 を試してみよう

概要

Consulの Web UI をnginxでリバースプロキシしようとしたらなぜか /ui/static/application.min.js で 「Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH」 とエラーが出て真っ白な状態に :scream_cat: 1

image

ローカルだと再現しなかったのでおそらくnginx側の設定の問題だろうと推測。

設定ファイル

/etc/nginx/sites-enabled/consul.conf
upstream consul {
  server 127.0.0.1:8500;
}

server {
  listen  80;
  server_name consul.example.com;
  root /var/www/consul;

  location / {
    proxy_read_timeout 60;
    proxy_connect_timeout 60;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://consul;
  }
}

エラー内容

/var/log/nginx/error.log
2016/05/31 15:19:00 [crit] 42702#0: *15 open() "/var/lib/nginx/tmp/proxy/3/00/0000000003" failed (13: Permission denied) while reading upstream, client: xxx.xxx.x.xxx, server: consul.example.com, request: "GET /ui/static/application.min.js HTTP/1.1", upstream: "http://127.0.0.1:8500/ui/static/application.min.js", host: "consul.example.com"

/var/lib/nginx/tmp/ 配下をパーミッション777にしたり、ディレクトリを作り直してnginxを再起動しても同様のエラーが出て解決せず。。。

解決方法

書き込みできないのなら一時ファイルを書き出さない設定はないかと思ってたら proxy_max_temp_file_size に行きつきました。

最終的には proxy_max_temp_file_size 0; をつけることでWeb UIを表示できるようになりました :smiley:

image

最終的な設定ファイル

/etc/nginx/sites-enabled/consul.conf
server {
  listen  80;
  server_name consul.example.com;
  root /var/www/consul;

  location / {
    proxy_read_timeout 60;
    proxy_connect_timeout 60;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://consul;
    proxy_max_temp_file_size 0; # <- 【これを追加】
  }
}

  1. ドメインが consul.example.com なのはローカルPCの /etc/hosts で直接IP指定しているからです 

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8