On 6/24/2018 10:25 PM, Ve Telko wrote:
> If you or your framework uses REQUEST_URI you don't need
> request rewrite feature. Using REQUEST_URI and request
> rewrite feature are two oposite solutions for the same problem.
> To mimic nginx's try_files do something like this:
>
> location match "/hello/.*" {
> ....
> root "/index.php"
> ....
> }
>
> It is not obvious from man page but file can act as document
> root :) Then in that file, index.php in this case, you can route
> requests by parsing $_SERVER['REQUEST_URI'] what your
> framework probably does.
Thank you for your reply. I finally got an opportunity to test your
suggested workaround, but it does not appear to work.
Request as logged in error log:
server nomina2.onomasticon.org, client 1 (1 active),
162.229.162.103:53790 -> 162.229.162.102:443, /hello/fred (404 Not Found)
Request as logged in access log:
nomina2.onomasticon.org 162.229.162.103 - scott [30/Jun/2018:10:20:47
-0700] "GET /hello/fred HTTP/1.1" 404 0
The index.php file is in the location specified:
$ ls -al /var/www/htdocs/lpn/src/public/
total 24
drwxr-xr-x 4 root daemon 512 Jun 21 13:13 .
drwxr-xr-x 5 root daemon 512 Jun 20 17:43 ..
-rw-r--r-- 1 root daemon 1081 Jun 23 07:00 index.php
....
From httpd.conf:
server "nomina2.onomasticon.org" {
listen on $ext_addr tls port 443
directory index index.php
root "/htdocs/lpn/src/public"
log access onom_access.log
log error onom_error.log
authenticate finklejinkleheimer with "/conf/ok_users"
tls certificate
"/etc/ssl/acme/nomina2.onomasticon.org/fullchain.pem"
tls key
"/etc/ssl/acme/private/nomina2.onomasticon.org/privkey.pem"
location "*.php" {
fastcgi socket "/run/php-fpm.sock"
}
location "/.well-known/acme-challenge/*" {
no authenticate
root "/htdocs/lpn/src/acme"
request strip 2
}
# Block user access to these files
location "/composer\.(json|lock)" {
block return 404
}
location match "/hello/.*" {
root "/htdocs/lpn/src/public/index.php"
}
location match "/old/(.*)" {
request rewrite "/new/%1"
}
}
server "nomina2.onomasticon.org" {
listen on $ext_addr port 80
block return 301 "https://$HTTP_HOST$REQUEST_URI"
}
No comments:
Post a Comment