Thursday, July 06, 2017

Re: httpd and URL rewriting

* Scott Vanderbilt [2017-07-06 09:25]:
> I am investigating the feasibility of migrating aRESTful webapp currently
> hosted on nginx and6.1-currentto use httpd. Naturally, such an application
> requires a URL-rewriting facility.

Does it really *require* URL rewriting?

> Perusing the httpd.conf(5) and httpd(8) man pages, this list's archive, and
> Google, I see nothing that indicates this is possible. Of course, I know you
> can redirect from within httpd, but that's obviously not thesort of behavior
> an app like this requires.
>
> I am encouraged by reyk@'s post to tech on 20 June 2015 wherein he says
> "Here is a diff that adds pattern matching to httpd, allowing rewrites with
> redirects." But that last bit is kind of ambiguous about whether rewrites
> independent of redirects can be achieved.
>
> Might anyone knowwhether this can be accomplished and how?

Below is working config for https://uptime.is/. You can put uptime
percentage after the slash, it it will work without redirect. In
addition, I made some redirects from common names to percents.
Config:

[...]
location "/" {
fastcgi
root "/htdocs/uptime/simple.cgi"
}
location match "^/%d+[,%.]?%d*$" {
fastcgi
root "/htdocs/uptime/simple.cgi"
}
location "/three-nines" {
block return 302 "/99.9"
}
[...]

The CGI script inspects the environment variable PATH_INFO.

> Many thanks.

--
-- Kirill Miazine <km@krot.org>

No comments:

Post a Comment