On Fri, Jun 22, 2018 at 12:08:07AM +0200, Mischa wrote:
> Hi tech@,
>
> Changed httpd.conf.5 to be more consistent with IPs used, all documentation
> IPs now.
> And added a couple of examples. 2 for dyamic pages, cgi and php.
> One fairly common used rewrite rule for things like wordpress.
>
> Mischa
>
hi.
the diff reads ok to me, but i cannot easily verify it because it does
not apply cleanly.
reyk?
jmc
> Index: httpd.conf.5
> ===================================================================
> RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
> retrieving revision 1.100
> diff -u -p -r1.100 httpd.conf.5
> --- httpd.conf.5 18 Jun 2018 06:04:25 -0000 1.100
> +++ httpd.conf.5 21 Jun 2018 21:55:38 -0000
> @@ -97,7 +97,7 @@ Macros are not expanded inside quotes.
> .Pp
> For example:
> .Bd -literal -offset indent
> -ext_ip="10.0.0.1"
> +ext_ip="203.0.113.1"
> server "default" {
> listen on $ext_ip port 80
> }
> @@ -198,6 +198,8 @@ argument can be used with return codes i
> .Sq Location:
> header for redirection to a specified URI.
> .Pp
> +It is possible to rewrite the request to redirect it to a different
> +external location.
> The
> .Ar uri
> may contain predefined macros that will be expanded at runtime:
> @@ -396,10 +398,10 @@ the
> using pattern matching instead of shell globbing rules,
> see
> .Xr patterns 7 .
> -The pattern may contain captures that can be used in the
> -.Ar uri
> -of an enclosed
> +The pattern may contain captures that can be used in an enclosed
> .Ic block return
> +or
> +.Ic request rewrite
> option.
> .It Oo Ic no Oc Ic log Op Ar option
> Set the specified logging options.
> @@ -462,6 +464,19 @@ in a location.
> Configure the options for the request path.
> Valid options are:
> .Bl -tag -width Ds
> +.It Oo Ic no Oc Ic rewrite Ar path
> +Enable or disable rewriting of the request.
> +Unlike the redirection with
> +.Ic block return ,
> +this will change the request path internally before
> +.Nm httpd
> +makes a final decision about the matching location.
> +The
> +.Ar path
> +argument may contain predefined macros that will be expanded at runtime.
> +See the
> +.Ic block return
> +option for the list of supported macros.
> .It Ic strip Ar number
> Strip
> .Ar number
> @@ -699,7 +714,7 @@ server "www.b.example.com" {
> }
>
> server "intranet.example.com" {
> - listen on 10.0.0.1 port 80
> + listen on 192.0.2.1 port 80
> root "/htdocs/intranet.example.com"
> }
> .Ed
> @@ -709,12 +724,43 @@ Simple redirections can be configured wi
> directive:
> .Bd -literal -offset indent
> server "example.com" {
> - listen on 10.0.0.1 port 80
> + listen on 203.0.113.1 port 80
> block return 301 "http://www.example.com$REQUEST_URI"
> }
>
> server "www.example.com" {
> - listen on 10.0.0.1 port 80
> + listen on 203.0.113.1 port 80
> +}
> +.Ed
> +.Pp
> +Serving dynamic pages can be defined with the
> +.Ic location
> +directive:
> +.Bd -literal -offset indent
> +server "www.example.com" {
> + listen on * port 80
> + location "/*.cgi*" {
> + fastcgi
> + root "/cgi-bin/"
> + }
> + location "/*.php*" {
> + fastcgi socket "/run/php-fpm.sock"
> + }
> +}
> +.Ed
> +.Pp
> +The request can also be rewritten with the
> +.Ic request rewrite
> +directive:
> +.Bd -literal -offset indent
> +server "www.example.com" {
> + listen on * port 80
> + location match "/old/(.*)" {
> + request rewrite "/new/%1"
> + }
> + location match "/([%a%d]+)" {
> + request rewrite "/dynamic/index.php?q=%1"
> + }
> }
> .Ed
> .Sh SEE ALSO
>