Re: rewriting requests (was: mod_fastcgi + php)

David Birnbaum <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
Gasior,

I don't think mod_fastcgi messes with the paths at all.  Take a look at 
mod_rewrite.  I think RewriteBase gives some clues as to how you can map a URL 
to a physical filesystem.  There is probably a way to do that with Rewrite and 
Alias combinations, but requires more wizardry than I can offer off the top of 
my head.

Your information might be nice to put into a FAQ question, once you get it all 
worked out though!

Cheers,

David.

-----

On Thu, 27 Oct 2005, Gasior wrote:

> I've managed to set up php as fastcgi application which is spawned
> inside chroot with appropriate UID/GID.
> Last problem to solve is to rewrite each requests that php gets and
> stript path outside chroot.
>
> Could you please help me, because I don't know mod_fastcgi architecture.
> My question is: does mod_fastcgi pass all requests to allready running
> fastcgi application or is it apache, that pass all *.php requests
> straight to running app.
>
> My guess is that mod_fastcgi passess all requests but I can't find it
> where in code i could patch it to strip path name passed to PHP.
>
> When I hit http://www.vhosts1.com/test.php apache translates it to
> /home/vhosts/vhost1.com/www/test.php, but PHP interpreter should get
> just /www/test.php. I've temporary solved that by setting symlinks
> inside chrooted filesystem but that's not an elegant sollution :(
>
> Thanks for your help
>
> Regards
> Gasior
>
>
> Gasior wrote:
>
>> Hi
>>
>> First of all I want to run different PHP binary for every VirtualHost
>> (it is the same binary, but differs in location). My wrapper figures out
>> which binary to use from PATH_INFO and PATH_TRANSLATED env variables.
>> When I execute wrapper from mod_fastcgi, whole environment is empty
>> (except for variables set by FastCgiConfig -initial-vars).
>> For me it looks like, mod_fastcgi executes wrapper, before apache sets
>> env variables corresponding to request (like DOCUMENT_ROOT etc.). Even
>> if  configured like this:
>>
>> FastCgiConfig -initial-env DOCUMENT_ROOT (or any other env like
>> HTTP_HOST/REQUEST_URI)
>>
>> when i read it with getenv in wrapper, it is empty (variable exists but
>> no value assigned)
>>
>> I've solved it by defining different application inside VirtualHost
>> directive like this:
>> <VirtualHost>
>>    ServerName vhost1.com
>>    DocumentRoot /home/vhosts/vhost1.com/www
>>
>>    ScriptAlias /cgi-vhost/ /home/vhosts/vhost1.com/usr/bin
>>
>>    AddHandler php-fastcgi .php
>>    <Location /cgi-vhost/php4-cgi>
>>       SetHandler fastcgi-script
>>    </Location>
>>
>>    Action php-fastcgi /cgi-vhost/php4-cgi
>>    AddType application/x-httpd-php .php
>>
>> </VirtualHost>
>>
>> Wrapper can find inside which VirtualHost it is by calling getcwd()
>> (/home/vhosts/vhost1.com/usr/bin) and chroot("../../"). chroot does not
>> close open descriptors, so php can communicate through open Unix socket.
>>
>> So there is one last thing to figure out. When apache gets reguest to
>> php file it forwards it to fastcgi application. So when calling
>> http://vhost1.com/info.php apache translates it to
>> /home/vhosts/vhost1.com/www/info.php and sends it to PHP binary
>> (allready running inside chroot).
>> So i have to find some way to strip this path to /www/info.php for this
>> to work.
>>
>> Any suggestions ?
>>
>> Regards
>> Gasior
>>
>>
>>
>
> ___________________________________
> fastcgi-developers mailing list
> http://fastcgi.com/fastcgi-developers/
>

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.