Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy: Exclude-list for specified hosts #6711

Closed
cupracer opened this issue Nov 21, 2014 · 2 comments
Closed

Proxy: Exclude-list for specified hosts #6711

cupracer opened this issue Nov 21, 2014 · 2 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously.

Comments

@cupracer
Copy link

Hi!

I'm using Piwik on a webserver in an internal network that requires an HTTP proxy to reach the internet for outgoing requests (i.e. DMOZ data). So I configured the [proxy] settings which are working fine.

The problem I'm facing the the fact, that the Piwik console uses these proxy settings also for archive jobs ("core:archive"). This results in an unnecessary loop, because the console doesn't try to work on the local host anymore. Instead it uses the proxy which then tries to connect back to the local host.

I've created a new [proxy] option called "excludes" which accepts a whitespace-separated list of hosts that should be accessed directly and added my local Piwik hostname to it.

These are the modifications I did:

"config/config.inc.php":

[proxy]
excludes = "myhostname.xy"; space-separated list of hosts

"core/Http.php":

164c164
< 

---
>       $proxyExcludes = explode(" ", Config::getInstance()->proxy['excludes']);
193a194,198
>             if(in_array($url['host'], $proxyExcludes))
>             {
>                 $proxyHost = '';
>             }
> 
386a392,405
>                 $url = @parse_url($aUrl);
>                 if ($url === false || !isset($url['scheme'])) {
>                     throw new Exception('Malformed URL: ' . $aUrl);
>                 }
> 
>                 if ($url['scheme'] != 'http') {
>                     throw new Exception('Invalid protocol/scheme: ' . $url['scheme']);
>                 }
> 
>                 if(in_array($url['host'], $proxyExcludes))
>                 {
>                     $proxyHost = '';                                                                                                                                                                                                                                         
>                 }                                                                                                                                                                                                                                                            
>                                                                                                                                                                                                                                                                              
422a442,455                                                                                                                                                                                                                                                                    
>           $url = @parse_url($aUrl);                                                                                                                                                                                                                                          
>             if ($url === false || !isset($url['scheme'])) {                                                                                                                                                                                                                  
>                 throw new Exception('Malformed URL: ' . $aUrl);                                                                                                                                                                                                              
>             }                                                                                                                                                                                                                                                                
>                                                                                                                                                                                                                                                                              
>             if ($url['scheme'] != 'http') {                                                                                                                                                                                                                                  
>                 throw new Exception('Invalid protocol/scheme: ' . $url['scheme']);                                                                                                                                                                                           
>             }                                                                                                                                                                                                                                                                
>                                                                                                                                                                                                                                                                              
>             if(in_array($url['host'], $proxyExcludes))                                                                                                                                                                                                                       
>             {                                                                                                                                                                                                                                                                
>                 $proxyHost = '';                                                                                                                                                                                                                                             
>             }                                                                                                                                                                                                                                                                
>                                                                                                                                                                                                                                                                              
777c810                                                                                                                                                                                                                                                                        
< }                                                                                                                                                                                                                                                                            
\ No newline at end of file                                                                                                                                                                                                                                                    
---                                                                                                                                                                                                                                                                            
> }

Would that be a proper fix for my problem?
It seems to work fine, but I'm not sure if this is sufficient or if this creates negative side-effects.
Would it be possible to add this fix (or an optimized version) to one of the next Piwik releases?

Thanks!
Thomas

@mattab
Copy link
Member

mattab commented Nov 25, 2014

Hi there, maybe another solution could be to "ignore" the proxy settings when attempting to contact a hostname where this hostname is found within the trusted_hosts array in config file?

@mattab
Copy link
Member

mattab commented Dec 1, 2014

This was also reported in: #315

@mattab mattab added Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously. labels Dec 1, 2014
@mattab mattab closed this as completed Dec 1, 2014
@mattab mattab modified the milestone: Short term Sep 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously.
Projects
None yet
Development

No branches or pull requests

2 participants