Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i am running safesquid and it does support an external parser, so i wrote this simple URL rewrite code in python which also logs the initial request...

#!/usr/bin/env python


import sys
def modify_url(line):
    list = line.split(' ')
    old_url = list[0]
    new_url = '\n'
    if old_url.endswith('.avi'):
        new_url = 'http://www.yahoo.com'
    else:
        new_url = old_url
    return new_url

def main():
    while True:
        line = sys.stdin.readline().strip()
        log = open('/tmp/redirect.log', 'a')
        log.write(line + "\n")
        log.close()
        new_url = modify_url(line)
        sys.stdout.write(new_url)
        sys.stdout.flush()

if __name__ == '__main__':
    main()

I get these errors on safesquid

2012 01 30 17:19:45 [225] request: request for web interface from 192.168.221.1
2012 01 30 17:19:45 [225] external: parsed with /opt/safesquid/safesquid/scripts/redirect.py
2012 01 30 17:19:45 [225] external: error: external parser sent null or invalid request headers
2012 01 30 17:19:45 [225] error: security: malformatted header received
2012 01 30 17:19:45 [225] external: parsed with /opt/safesquid/safesquid/scripts/redirect.py
2012 01 30 17:19:45 [225] external: error: external parser sent null or invalid request headers

Also the initial request log is EMPTY however the file is large, i guess it must be appending "\n" to the file....

Any ideas how i can capture the requests from safesquid?

share|improve this question

1 Answer 1

If you want to rewrite or redirect a URL, then you can simply use the URL Redirect or Re-Write Document feature of SafeSquid.

share|improve this answer
    
thats ok, but i need to run an external program which does some checks on my internal database... –  krisdigitx Jan 31 '12 at 9:30

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.