I have an application on my server that is for the most part overwriting Apache. Now I want to install PhpMyAdmin on my VPS, it doesn't work (displays directory listing instead of UI), but by asking around on few sites plus some trial and error I realized I'm trying to run PhpMyAdmin through my application (Traccar) instead through Apache.
Now back to the topic. I'm on Ubuntu Server 18.04 and I have the following site configuration:
Listen 80 <IfModule mod_ssl.c> <VirtualHost *:80> ServerName x.example.com Redirect / https://x.example.com </VirtualHost> <VirtualHost *:443> ServerName x.example.com DocumentRoot /var/www/html ServerAdmin admin@localhost ProxyPass /api/socket ws://localhost:app_port/api/socket ProxyPassReverse /api/socket ws://localhost:app_port/api/socket ProxyPass /phpmyadmin ! ProxyPass / http://localhost:app_port/ ProxyPassReverse / http://localhost:app_port/ SSLEngine on SSLOptions +StrictRequire SSLProtocol TLSv1 ServerAlias x.example.com SSLCertificateFile /etc/letsencrypt/live/x.example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/x.example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule>
The way I want it to work:
If I connect to x.example.com I get redirected to my application. Works properly.
If I connect to x.example.com/phpmyadmin I want to receive PhpMyAdmin UI. I receive a "too many redirects" error instead.
When I access phpmyadmin directory the rewrite log keeps alternating between these two messages in the server log:
[Fri May 10 10:32:38.733370 2019] [rewrite:trace1] [pid 19228] mod_rewrite.c(482): [client xxx.xxx.xxx.xxx:yyyy] xxx.xxx.xxx.xxx - - [x.example.com/sid#7f34cd331cc0][rid#7f34cd2640a0/initial] pass through /phpmyadmin [Fri May 10 10:32:38.767398 2019] [rewrite:trace2] [pid 19228] mod_rewrite.c(482): [client xxx.xxx.xxx.xxx:yyyy] xxx.xxx.xxx.xxx - - [x.example.com/sid#7f34cd331cc0][rid#7f34cd2620a0/initial] init rewrite engine with requested uri /phpmyadmin
This is what I receive when I wget to x.example.com/phpmyadmin:
--2019-05-10 10:43:19-- https://x.example.com/phpmyadmin Resolving x.example.com (x.example.com)... 188.8.131.52 Connecting to x.example.com (x.example.com)|184.108.40.206|:443... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://x.example.com/phpmyadmin [following] --2019-05-10 10:43:19-- https://x.example.com/phpmyadmin Reusing existing connection to x.example.com:443. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://x.example.com/phpmyadmin [following] --2019-05-10 10:43:19-- https://x.example.com/phpmyadmin Reusing existing connection to x.example.com:443.
The lines repeat until they reach 20 redirections.
If I curl to x.example.com/phpmyadmin I get this:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html> <head> <title>302 Found</title> </head> <body> <h1>Found</h1> <p>The document has moved <a href="https://x.example.comphpmyadmin">here</a>.</p> <hr> <address>Apache/2.4.29 (Ubuntu) Server at x.example.com Port 80</address> </body> </html>