Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any way in which I can, on OS X, effectively block against access (by browsers or potentially any process) to secure URLs by regex?

E.g. deny access to: https://example.com/foo/bar/.*

but at the same time allow access to all other non-matching URLs under https://example.com/

I'm not looking for a solution which involves browser extensions, but that would work automatically for any browser and any fresh (extensionless) browser profile.

Thanks.

share|improve this question
    
Is this possible on any system? –  Daniel Beck May 15 '11 at 18:01
1  
@Daniel why not, with the appropriate proxy? –  slhck May 15 '11 at 18:21
    
@slhck HTTPS requests contain the path fragment of an URL in plain text? Seriously? (I know nothing about HTTPS... I always thought everything was encrypted and the requested length could be used for side-channel attacks...) –  Daniel Beck May 15 '11 at 19:31
    
@Daniel Oh, valid point though, I didn't realize this at first! (Should look into the appropriate standards/RFCs some time) –  slhck May 15 '11 at 19:38
add comment

1 Answer

up vote 0 down vote accepted

You can use a proxy auto-config (PAC) file to do this if all your applications honor system proxy settings. It is a JavaScript file declaring a single function FindProxyForURL(), which provides the web browser the proxy setting for a URL. You just need to return a non-working proxy setting to prevent a connection from happening.

var normal = "DIRECT", blackhole = "PROXY 127.0.0.1:3421";

function FindProxyForURL(url, host) {
    if(/^https:\/\/example.com\/foo\/bar\//i.test(url)) {
        return blackhole;
    }
    return normal;
}

You need to use a file URL to load the PAC file from the local hard drive. Enter this URL as the system proxy setting in the Network System Preferences panel.

This approach has been used before – see no-ads for an example of such a script that blocks many URLs.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.