Wednesday, January 25, 2023

httpd(8) request rewrite - 500 internal server error

Hi all,

I was trying to do a basic path rewrite in httpd(8) on 7.2-stable, and I just can't see what I'm missing:

httpd.conf:
server "host" {
listen on egress port 12345

root "/htdocs"

location "/" {
request rewrite "/to/"
}
location "/*" {
directory auto index
}
}


Using http://host:12345/ slaps me with 500:

server_response: rewrote /? -> /to/?
"GET / HTTP/1.1" 500 0
, /to/ (500 Internal Server Error)


Accessing http://host:12345/to/ directly works, however:

"GET /to/ HTTP/1.1" 200 538
"GET /favicon.ico HTTP/1.1" 404 0
, /favicon.ico (404 Not Found)


I though maybe it was iffy because of the location containing only a slash (/), but using anything else like...:
location "/from/" {
request rewrite "/to/"
}

... gives 500 too when accessing http://host:12345/from/
Tried playing around with (adding/removing) the trailing '/' from the paths, but still no luck. I even tried the example at the end of httpd.conf(5) with "location match" and pattern/captures, but still the same.

But "request rewrite" must be clearly working somehow, I just can't see what's missing.

Any tips would be greatly appreciated!


Daniel

No comments:

Post a Comment