Sample Header Ad - 728x90

RewriteRule overrides ProxyPass

2 votes
2 answers
2757 views
On a centos 7 machine, I'd like to run a python server alongside an apache server. I figured the easiest way would be to configure apache as a reverse proxy. This is my VirtualHost configuration: DocumentRoot /home/username/mydomain/src ServerName mydomain.com ErrorLog logs/mydomain-error_log CustomLog logs/mydomain-access_log common DirectoryIndex index.php Options -Indexes +FollowSymLinks AllowOverride None Require all granted AddOutputFilterByType DEFLATE text/html text/plain text/xml ProxyPreserveHost On ProxyPass /mediaproxy http://127.0.0.1:9001/mediaproxy ProxyPassReverse /mediaproxy http://127.0.0.1:9001/mediaproxy LogLevel alert rewrite:trace6 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/api/media/(.*) /data/$1 [L] RewriteRule ^/api/v1/* /api/v1/index.php [L] RewriteRule ^/assets/(.*) /site/v1/content/assets/$1 [L] RewriteRule ^/css/(.*) /site/v1/content/css/$1 [L] RewriteRule ^/js/(.*) /site/v1/content/js/$1 [L] RewriteRule ^/fonts/(.*) /site/v1/content/fonts/$1 [L] RewriteRule ^/* /index.php [L] # problematic rule // lets encrypt entries Now, my problem is that rewrite rules takes precedence over ProxyPass. That ism when I visit mydomain.com/mediaproxy/somepage, it serves the content at /index.php, specified with RewriteRule ^/* /index.php [L] . Reverse proxy works correctly if I remove the problematic rule. Unfortunately I need to keep it. How do I tell apache to use ProxyPass rule first, and use RewriteRule only if there is no match?
Asked by sanjihan (415 rep)
Aug 4, 2022, 07:51 PM
Last activity: Aug 10, 2022, 06:59 PM