ProxyPass/RewriteRule and FastCGI not working after migration to LiteSpeed

Bubba

New Member
#1
Greetings,

on Apache2 (CPanel/CentOS VPS), we had simple case/scenario:

Code:
ProxyPass /fcgi/ fcgi://localhost:5600/
or
Code:
RewriteRule /fcgi(.*) http://127.0.0.1:5600/$1 [p]
Those redirects return empty response on LiteSpeed. Reverting it back to Apache2 - works flawlessly.

We have tried with vhost entries but that fails as well. Our VPS provider has pretty much ran out of options (and they really tried their best).

FastCGI application is a C/ASM custom code and as said, works perfectly on Apache2, both on CPanel or locally as a test.

Any clues what might have gone wrong in the process?

With my best,

Bruno
 

Bubba

New Member
#3
Greetings NiteWave,

thank you very much for your quick reply. We have tried several options but without success. To begin with, it seems that instructions you provided aren't exact match for our case, since they describe proxying for an external HTTP application, and we need to proxy to a (local) FastCGI application.

Hoping for the simplest configuration possible, we tried simply adding an external FastCGI application at 127.0.0.1:5600 to the global "Server" LiteSpeed configuration section, and using the name of the application in .htaccess. This had no effect.

We then removed the external applications and tried to follow the provided instructions as closely as possible ( http://open.litespeedtech.com/media...proxy_.28web_server.29_external_application_2 ).

We created a vhost in the LSWS web admin console and added an external application to the vhost, named vhost-proxy1.

With both of the above configurations (ExtApp at the server level, and ExtApp in a vhost), we tried a few variations of existing rewrite rules with no success:

Code:
root [/home/domain/public_html]# cat .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
#RewriteRule ^fcgi\/?$ "http\:\/\/domain\.com\:5600\/" [R=301,L]

#RewriteRule /fcgi/(.*) http://127.0.0.1:5600/$1 [p] #works with apache
#RewriteRule /fcgi/(.*) fcgi://vhost-proxy1/$1 [p] # attempt
#RewriteRule /fcgi/(.*) vhost-proxy1/$1 [p] # attempt
RewriteRule ^/fcgi/(.*)$ fcgi://vhost-proxy1/$1 [p] # attempt
#ProxyPass /fcgi/ fcgi://127.0.0.1:5600/
root [/home/domain/public_html]#
Unfortunately LSWS isn't logging any errors when it parses the .htaccess file.

At this point we are not sure whether the workaround provided on the LSWS form conflicts with LSWS APVH virtual hosts, or if the issue is simply rewrite syntax.

Is this workaround compatible at all with the cPanel/WHM virtual hosts and the LSWS WHM plugin?

Thank you in advance,

Bruno
 
L

Long

Guest
#4
Hi, Bruno,

The procedures to set up ols as reverse proxy doesn't apply to lsws.
It won't work.

In lsws, you can try a server level script handler config,
then force MIME_type to the MIME type associated with the script handler.
Forcing MIME type can be done through rewrite.
 

NiteWave

Administrator
#5
Hi Bruno,
Today I got time to try on lsws. Sorry for late.
Hoping for the simplest configuration possible, we tried simply adding an external FastCGI application at 127.0.0.1:5600 to the global "Server" LiteSpeed configuration section, and using the name of the application in .htaccess. This had no effect.
this step is right.

the next step, I don't think at present lsws support
RewriteRule ^/fcgi/(.*)$ fcgi://vhost-proxy1/$1 [p]
but support http:// only

for apache 2.4 mod_proxy_fcgi (https://httpd.apache.org/docs/current/mod/mod_proxy_fcgi.html) directive:
ProxyPass"/myapp/""fcgi://localhost:4000/"

it can be done easily on litespeed native virtual host.
select an native virtual host -> Context

I tried to install php-fpm on a CentOS 6.5 box:
#yum install php-fpm
#service php-fpm start
then I can see
#netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 8718/php-fpm

how to configure it in native virtual host:
select an native virtual host -> Context -> Add -> Type: Fast CGI
URI:/fcgi/
Fast CGI App: [Server Level]: php-fpm

then
test-web-site/phpinfo.php
Server API LiteSpeed V6.9

test-web-site/fcgi/phpinfo.php
Server API FPM/FastCGI
 
Top