php-proxy icon indicating copy to clipboard operation
php-proxy copied to clipboard

support a separate file for configuration settings

Open tpokorra opened this issue 1 year ago • 2 comments

Thanks for this great script!

I don't like changing Proxy.php for settings, for example if I want to hardcode the TARGET_URL. See attached Pull Request.

tpokorra avatar Sep 19 '22 13:09 tpokorra

Thanks for the pull request! 🙂 From what I see, the same could be achieved by calling this at your application startup (or anywhere before using the proxy):

Proxy::$AUTH_KEY = 'Bj5pnZEX6DkcG6Nz6AjDUT1bvcGRVhRaXDuKDX9CjsEs2';
Proxy::$ENABLE_AUTH = true;
Proxy::$DEBUG = false;
Proxy::$TARGET_URL = "";

The configuration variables are public static, thus you can change them anytime. Would that fit your use case?

zounar avatar Sep 19 '22 13:09 zounar

In my usecase, I am using a htaccess like this:

RewriteEngine On
RewriteBase /

# no parameter
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^$
RewriteRule . https://www.beispielverein.de/?test1 [R=302,L]

# avoid direct access to Proxy.php
RewriteCond %{REQUEST_URI} ^/Proxy.php$
RewriteRule . https://www.beispielverein.de/?test1 [R=302,L]

RewriteCond %{QUERY_STRING} !^page_id=[0-9]+&civiwp=CiviCRM&q=civicrm%2Fcontribute%2Ftransact.*$
RewriteCond %{QUERY_STRING} !^page_id=[0-9]+&civiwp=CiviCRM&q=civicrm%2Fajax%2Frest.*$
RewriteRule . - [R=403,L]

FallbackResource /Proxy.php

So Proxy.php is the fallback, and directly called. The goal is to prevent access to the CRM system, but only allow access to the public forms of the CRM system.

Ok, I understand now, I could set it all up with composer, and have an index.php instead, which uses Zounar\PHPProxy\Proxy.

tpokorra avatar Sep 19 '22 15:09 tpokorra