work environment: Ubuntu 13.10 saucy, apache2 2.4.6
I have a python script in /usr/lib/cgi-bin and I use it as a proxy for convert internal url to external. it works great with apache 2.2 but always got 403 forbidden error.
/etc/apache2/site-enabled/mirror.conf
ScriptAlias /mirror /usr/lib/cgi-bin/mirror.py
/usr/lib/cgi-bin/mirror.py
#!/usr/bin/python
import os
import sys
import pycurl
username = "username"
password = "password"
base = "https://mirror.xxxxxxxx.com/xxxxxxxx"
if os.environ.has_key(‘PATH_INFO’):
path = os.environ[‘PATH_INFO’]
else:
path = ‘/’
dst = base + path
def write(data):
sys.stdout.write(data)
def header(data):
for line in data.splitlines():
if line.startswith('HTTP/'):
ret = line.split()[1]
sys.stdout.write('Status: ' + ret + '\r\n')
elif line.startswith('Location:'):
line = line.replace('https://mirror.xxxxxxxx.com/xxxxxxxx', 'http://mirror.internal/mirror')
sys.stdout.write(line + '\r\n')
else:
sys.stdout.write(line + '\r\n')
curl = pycurl.Curl()
curl.setopt(curl.URL, dst)
curl.setopt(curl.HEADERFUNCTION, header)
curl.setopt(curl.USERPWD, '%s:%s' % (username, password))
curl.setopt(curl.WRITEFUNCTION, write)
curl.perform()
curl.close()
any tips for apache new version I should follow?