Reverse proxy with prefix stripping?

jdh

New Member
#1
Hi all,

I'm trying to set up a reverse proxy to ensure I can access a phpymadmin docker container securely. The idea is for phpmyadmin to be available under example.com/phpymadmin in a secure realm. However, as soon as I launch the config, PHPMyAdmin throws 404 errors, ostensibly as a result of being in a subdirectory rather than the document root.

In order to resolve this, I thought I'd try a rewrite rule to strip the /phpmyadmin prefix, but this too doesn't work:

RewriteEngine On
RewriteRule ^/phpmyadmin/(.*)$ /$1 [L]


Apparently, OLS performs the rewrite rule first, and as a result the request never reaches the proxy, which explains why I get a server 404. I've tried changing the whole setup to a rewrite-only proxy (no context), but this doesn't seem to work in activating the 'secure' realm (I can access the phpmyadmin app without HTTP auth), which is a non-starter:

RewriteEngine On
# Enforce authentication for /phpmyadmin
RewriteCond %{REQUEST_URI} ^/phpmyadmin
RewriteRule .* - [E=REALM:secure]
# Proxy requests to the phpMyAdmin backend
RewriteRule ^/phpmyadmin/(.*)$ http://127.0.0.1:1004/$1 [P]


I've kind of hacked my way around this by creating a symlink inside the phpmyadmin container, but this is 'dirty', and I'm convinced there has got to be a way to do this natively inside OpenLiteSpeed.

Does anybody have any ideas?
 
Top