Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Attempt to fix issues with POST and multipart/form-data
Browse files Browse the repository at this point in the history
Also fix issue that caused openresty `--with-debug` to fail to start up.
  • Loading branch information
jspiewak committed Jun 1, 2017
1 parent c513b17 commit d27acca
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lua/src/bin/init_redx.lua
Expand Up @@ -20,4 +20,5 @@ for i, plugin in ipairs(config.plugins) do
}
end
math.randomseed(socket.gettime() * 1000)
return library.log('Redis host: ' .. config.redis_host .. ':' .. config.redis_port)
library.log('Redis host: ' .. config.redis_host .. ':' .. config.redis_port)
return nil
4 changes: 0 additions & 4 deletions lua/src/bin/main.lua
Expand Up @@ -8,8 +8,6 @@ lapis_config.config("development", function()
session_name("redx_session")
return secret(config.cookie_secret)
end)
ngx.req.read_body()
local request_body = ngx.req.get_body_data()
local process_request
process_request = function(request)
local frontend = redis.fetch_frontend(request, config.max_path_length)
Expand Down Expand Up @@ -74,8 +72,6 @@ process_request = function(request)
ngx.req.set_header("X-Redx-Backend-Cache-Hit", "true")
ngx.req.set_header("X-Redx-Backend-Server", session['server'])
library.log("SERVER: " .. session['server'])
ngx.req.set_body_data = request_body
request_body = nil
ngx.var.upstream = session['server']
end
end
Expand Down
1 change: 1 addition & 0 deletions nginx.conf.example
Expand Up @@ -36,6 +36,7 @@ http {

listen 8080;
lua_code_cache off;
lua_need_request_body on;

proxy_read_timeout 300;
proxy_connect_timeout 3;
Expand Down
2 changes: 2 additions & 0 deletions src/bin/init_redx.moon
Expand Up @@ -25,3 +25,5 @@ for i, plugin in ipairs config.plugins
math.randomseed(socket.gettime! * 1000)

library.log('Redis host: ' .. config.redis_host .. ':' .. config.redis_port)

return nil
7 changes: 0 additions & 7 deletions src/bin/main.moon
Expand Up @@ -10,11 +10,6 @@ lapis_config.config "development", ->
session_name "redx_session"
secret config.cookie_secret

-- get request body, so we can make sure it gets forwarded to the upstream and lapis doesn't swallow it up
-- https://github.com/leafo/lapis/issues/161
ngx.req.read_body!
request_body = ngx.req.get_body_data!

process_request = (request) ->
frontend = redis.fetch_frontend(request, config.max_path_length)
if frontend == nil
Expand Down Expand Up @@ -70,8 +65,6 @@ process_request = (request) ->
ngx.req.set_header("X-Redx-Backend-Cache-Hit", "true")
ngx.req.set_header("X-Redx-Backend-Server", session['server'])
library.log("SERVER: " .. session['server'])
ngx.req.set_body_data = request_body
request_body = nil -- clear body from memory (GC)
ngx.var.upstream = session['server']
return nil

Expand Down

0 comments on commit d27acca

Please sign in to comment.