I've setup a squid proxy on a ubuntu 14.04 and it works fine except for the url_rewrite_program.
My url_rewrite_program conf settings are:
url_rewrite_program /usr/bin/python /etc/squid3/replace_url.py url_rewrite_children 20 url_rewrite_access allow all url_rewrite_bypass on
url_replace.py
import sys url = 'https://img.com/img.jpg' def replace_url(line): alist = line.split(' ') old_url = alist[0] new_url = '\n' if old_url.lower().endswith('.jpg'): new_url = url + '\n' return new_url while True: line = sys.stdin.readline().strip() new_url = replace_url(line) sys.stdout.write.(new_url) sys.stdout.flush()
I want the proxy to replace all .jpg images with a predetermined url pointing to a .jpg. What happens instead is most GET requests to jpgs end up with 400 errors.
When I try to access a .jpg url directly I get this error message
The following error was encountered while trying to retrieve the URL: https://img.com/img.jpg Unsupported Request Method and Protocol Squid does not support all request methods for all access protocols. For example, you can not POST a Gopher request. Your cache administrator is webmaster.
I can provide more info on my squid proxy config, I only posted the configs that I thought were relevant.
Any insight on where my problem lies or how to fix it would be much appreciated. Thank you in advance!
[link][comment]