How to create conditional ProxyPass?
I have the following config for one of the sites-available .conf
file.
Its configure to load the ghost
blog if you hit blog.example.com
.
Somehow its causing example.com
to serve up the blog as well. But thats fine too.
<Virtualhost *:80>
ServerName blog.example.com
ServerAdmin [email protected]
ProxyPass / http://localhost:2368/
ProxyPassReverse / http://localhost:2368/
</Virtualhost>
So I just installed phpmyadmin
and I realized I can't access it with http://example.com/phpmyadmin
. Accessing that page will bring up ghost's 404 page not found instead.
So I guess I need some conditional ProxyPass
to ignore /phpmyadmin
?
I tried the following by it doesn't work too.
<Virtualhost *:80>
ServerName blog.example.com
ServerAdmin [email protected]
ProxyPass /phpmyadmin http://localhost/phpmyadmin
ProxyPassReverse /phpmyadmin http://localhost/phpmyadmin
ProxyPass / http://localhost:2368/
ProxyPassReverse / http://localhost:2368/
</Virtualhost>
Apache just hang and I have to restart it when I hit http://example.com/phpmyadmin
.
Update:
I tried the following, and it loads up phpmyadmin
login page. Just added :80
after localhost. and give a specific domain name for the virtual host instead of *
.
<Virtualhost blog.example.com:80>
ServerName blog.example.com
ServerAdmin [email protected]
ProxyPass /phpmyadmin http://localhost:80/phpmyadmin
ProxyPassReverse /phpmyadmin http://localhost:80/phpmyadmin
ProxyPass / http://localhost:2368/
ProxyPassReverse / http://localhost:2368/
</Virtualhost>
Problem now is, it redirects to http://localhost/phpmyadmin/index.php?token=8fa78a71a166399749b58cd3cb66b7f2
instead. Probably some configuration with phpmyadmin
I guess.
Solution 1:
You can use the !
target to prevent a location to be proxied:
<Virtualhost *:80>
DocumentRoot /path/to/parent/of/phpmyadmin
ProxyPass /phpmyadmin !
ProxyPass / http://localhost:2368/
ProxyPassReverse / http://localhost:2368/
</Virtualhost>
This will proxy all requests to localhost:2368
, except those to phpmyadmin.
Of course you'll have to set a document root, otherwise phpmyadmin won't be found.