Skip to content

Commit

Permalink
Added reverse proxy support via HTTP_X_SCRIPT_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyhorner committed Apr 20, 2011
1 parent b06fe17 commit e296226
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Rack/R/Request.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,26 @@ Request <- setRefClass(
'multipart/mixed'
)

# Adjust script name if we're sitting behind a reverse proxy
#
# Nginx example config:
#
# location /rhttpd {
# rewrite ^/rhttpd(.*)$ $1 break;
# proxy_pass http://127.0.0.1:12344;
# proxy_set_header X-Script-Name /rhttpd;
# }
#

if (exists('HTTP_X_SCRIPT_NAME',env)){
env[['HTTP_X_SCRIPT_NAME']] <<- sub('/$','',env[['HTTP_X_SCRIPT_NAME']])
env[['SCRIPT_NAME']] <<- paste(env[['HTTP_X_SCRIPT_NAME']],env[['SCRIPT_NAME']],sep='')
}

callSuper(...)
},
body = function() env[["rack.input"]],
scheme = function() env[["rack.url_scheme"]],
script_name = function() env[["SCRIPT_NAME"]],
path_info = function() env[["PATH_INFO"]],
port = function() as.integer(env[["SERVER_PORT"]]),
request_method = function() env[["REQUEST_METHOD"]],
Expand Down

0 comments on commit e296226

Please sign in to comment.