Stuart Henderson писал(а) 2024-10-22 11:45:
On 2024-10-19, kasak <ka...@kasakoff.net> wrote:
hello misc!
I know that apache has it's own module for cgi execution, but
unfortunately, it works only with mpm_prefork module.
There are two: mod_cgi (what you're talking about) and mod_cgid (uses a
seoarate daemon and works with a multithreaded MPM).
So, the question is: is it possible to forward requests to slowcgi?
I've tried this configuration ( basically this is a copy of similar
php-fpm option )
<VirtualHost *:80>
ServerName gw.kasakoff.net
DocumentRoot /var/www/htdocs/gw
Alias "/dhcpd-leasesd/" "/var/www/dhcpd-leasesd/"
<Directory "/var/www/dhcpd-leasesd">
SetHandler
"proxy:unix:/var/www/run/slowcgi.sock|fcgi://localhost"
Require ip 192.168.0.
</Directory>
</VirtualHost>
And slowcgi -dv -p/
mx$ doas slowcgi -dv -p/
...
slowcgi: env[24],
SCRIPT_FILENAME=proxy:fcgi://localhost/var/www/dhcpd-leasesd/dhcpd-leasesd
...
slowcgi: fork:
proxy:fcgi://localhost/var/www/dhcpd-leasesd/dhcpd-leasesd
slowcgi: wait:
proxy:fcgi://localhost/var/www/dhcpd-leasesd/dhcpd-leasesd
unfortunately this does not work due to errors:
Oct 19 08:01:24 mx slowcgi[25467]: cannot chdir to
proxy:fcgi://localhost/var/www/dhcpd-leasesd: No such file or
directory
Oct 19 08:01:24 mx slowcgi[25467]: execve
proxy:fcgi://localhost/var/www/dhcpd-leasesd/dhcpd-leasesd: No such
file
or directory
I've not tried this, but it looks like you should be able to construct
a SCRIPT_FILENAME variable suitable for slowcgi (containing just the
path to the script without proxy:fcgi://localhost) by using
ProxyFCGISetEnvIf.
(Not relevant for you as you have -p/ but for someone else finding this
post, if chroot()ing to the default /var/www, the chroot prefix will
need to be stripped from the path to the script in SCRIPT_FILENAME).
Stuart, thank you! This is not the first time you impress me with
encyclopedic knowledge of everything!
Both of your statements worked out!
At first, I tried this config in apache:
<VirtualHost *:80>
ServerName gw.kasakoff.net
DocumentRoot /var/www/htdocs/gw
Alias "/dhcpd-leasesd/" "/var/www/dhcpd-leasesd/"
<Directory "/var/www/dhcpd-leasesd">
Require ip 192.168.0.
SetHandler
"proxy:unix:/var/www/run/slowcgi.sock|fcgi://localhost"
ProxyFCGISetEnvIf "true" SCRIPT_FILENAME
/var/www%{reqenv:SCRIPT_NAME}
</Directory>
</VirtualHost>
And indeed this worked like a charm!
And after that, you were right about apache module cgid. I'm feeling
really stupid, not to notice it myself.
So, the answer for my question is: YES. It IS possible to run slowcgi
with apache and worker. But, you found even better way.