307 redirection in mruby fail to maintain the METHOD as POST
Author: foalfordCreated May 17, 2026Updated May 17, 2026
Is the issue intended or a potential bug?
According to the manual, status 307/308 shall maintain the original request method. It can be used for rewrite URLs. However, it redirect a POST request to a GET request in the certain condition that file.dir: /path/to/scripts is used. Here is the reproduction config:
h2o.conf
file.index: [ 'test.php', 'index.php' ]
hosts:
"127.0.0.1:8080":
paths:
"/":
mruby.handler: |
Proc.new do |env|
[307, {"x-reproxy-url" => "/test.php"}, []]
end
reproxy: on
"/test.php":
# Problematic
file.dir: /var/www/root
# This is a fix
# file.file: /var/www/root/test.php
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm/php-fpm.sock
type: unix
test.php
<?php echo 'Method:'; var_dump($_SERVER['REQUEST_METHOD'] );
Curl
curl -v -d 'test=123' http://127.0.0.1:8080/start
This issue can be fixed by using
file.file: /var/www/root/test.php
Sidenote, this config can be easily extended to work as url rewrite for many PHP applications such as wordpress, dokuwiki etc.
Source: h2o/h2o