2017-10-20 103 views
0

AWS HealthCheck端點不會發送任何會導致Cowboy(v 1.1.2)返回400的標頭。這會導致容器重新啓動。牛仔返回400無標頭

有什麼辦法解決這個問題嗎?

相關github上的問題:https://github.com/phoenixframework/phoenix/issues/2437

捲曲請求重現錯誤:

curl http://localhost:4000/ping -H 'Host:' 

登錄:

[error] Cowboy returned 400 and there are no headers in the connection. 

This may happen if Cowboy is unable to parse the request headers, 
for example, because there are too many headers or the header name 
or value are too large (such as a large cookie). 

You can customize those values when configuring your http/https 
server. The configuration option and default values are shown below: 

    protocol_options: [ 
     max_header_name_length: 64, 
     max_header_value_length: 4096, 
     max_headers: 100 
    ] 

端點配置:

config :my_app, MyAppWeb.Endpoint, 
    load_from_system_env: true, 
    url: [host: System.get_env("MY_HOST"), port: 443], 
    force_ssl: [rewrite_on: [:x_forwarded_proto]] 
+1

HTTP協議中需要主機頭:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host – narrowtux

回答

0

我結束了使用以下端點配置運行服務器:

config :my_app, MyAppWeb.Endpoint, 
    load_from_system_env: true, 
    http: [port: 4000] 

並且問題已解決。

這可能與牛仔在ELB後面運行https服務器的事實有關。