Skip to content

Instantly share code, notes, and snippets.

@gawin
Last active October 16, 2017 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gawin/e971395dda56464432d1114580be9b45 to your computer and use it in GitHub Desktop.
Save gawin/e971395dda56464432d1114580be9b45 to your computer and use it in GitHub Desktop.

ERR_SPDY_PROTOCOL_ERROR

Today I found myself in the situation where web pages were not fully served or randomly hang. Often triggering a ERR_SPDY_PROTOCOL_ERROR. First, I suspected this was due to CloudFlare. After some investigation, I found it was my own NGINX installation that was lacking.

Apparently the build of NGINX that came with OpenResty didn't have the tmp_paths set correctly. This can be fixed during the configuration of the build, or afterwards in the configuration files itself. Which was kind of fun since this app didn't use OpenResty but only Sinatra served by Puma and RACK.

NGINX error.log

[crit] 22084#0: *142 open() "/var/lib/nginx/proxy/1/01/0000000011" failed (13: Permission denied) while reading upstream, client: 111.111.111.111, server: my_app.example.com, request: "GET /path HTTP/1.1", upstream: "http://unix:///path/to/app/tmp/puma.sock:/path", host: "my_app.example.com", referrer: "https://my_app.example.com/path"

[error] 25632#0: *30 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 111.111.111.111, server: my_app.example.com, request: "GET /path HTTP/1.1", upstream: "http://unix:///path/to/app/tmp/puma.sock:/path", host: "my_app.example.com", referrer: "https://my_app.example.com/path"

Fixed NGINX .conf example

upstream my_app {
  server unix:///path/to/app/tmp/puma.sock;
}
server {
  listen 80;
  server_name my_app.example.com;

  client_body_temp_path /path/to/app/tmp/client_body;
  fastcgi_temp_path     /path/to/app/tmp/fastcgi;
  proxy_temp_path       /path/to/app/tmp/proxy;
  scgi_temp_path        /path/to/app/tmp/scgi;
  uwsgi_temp_path       /path/to/app/tmp/uwsgi;

  location / {
    root /path/to/app/src;
    proxy_pass http://my_app;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Note that adding the 5 *_temp_path's above saved the day.

@stevemulligan
Copy link

Similar to @davidbell I was sending a header that was "application/json" instead of "Content-type: application/json". A very confusing error message.

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