On Fri, Aug 30, 2019 at 04:59:36PM -0500, J. Lewis Muir wrote:
Hi there,
> I was wishing for a way to specify a new root but with a modified
> request URI. So, I tried the alias directive, and I assumed that
> $document_root and $realpath_root would refer to the aliased document
> root, but obviously that can't be since nginx has no way of knowing what
> the aliased document root should be when all it has is a location alias
> which is the full path to the resource. Sorry for the trouble.
It sounds like your desires are for requests:
* starts with /my-app/current/ -> reject
* starts with /my-app/releases/ -> reject
* matches /my-app/something.php, or /myapp/something.php/anything ->
fastcgi-process the file /srv/www/my-app/current/something.php
* matches /my-app/something -> just send the file
/srv/www/my-app/current/something
Is that correct? If so -- do exactly that.
For example (but mostly untested):
==
location ^~ /my-app/current/ { return 200 "nothing to see at /current/\n"; }
location ^~ /my-app/releases/ { return 200 "nothing to see at /releases/\n"; }
location ^~ /my-app/ {
location ~ \.php($|/) {
fastcgi_split_path_info ^/my-app(/.*php)(.*);
root /srv/www/my-app/current/;
include fastcgi.conf;
fastcgi_pass unix:php.sock;
}
alias /srv/www/my-app/current/;
}
==
Change the "return"s to 404s or whatever; change the "fastcgi_pass"
destination; and don't worry about internal rewrites unless you need them.
fastcgi.conf presumably sets SCRIPT_FILENAME and PATH_INFO and whatever
else is interesting to sensible values; if not, add suitable fastcgi_param
values explicitly here.
You might want an "index index.php" somewhere to handle the request
for /my-app/.
But hopefully, any parts that don't Just Work as-is will leave enough
clues to allow you to find or ask for the solution.
Good luck with it,
f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx