import subprocess
# test what nginx serves for phpmyadmin with various Host headers
tests=[('http://127.0.0.1/phpmyadmin/index.php','localhost'),
       ('http://127.0.0.1/phpmyadmin/index.php','glark.ru'),
       ('http://127.0.0.1/','localhost'),
       ('http://127.0.0.1/','glark.ru')]
for url,host in tests:
    try:
        out=subprocess.check_output(['curl','-s','-m','8','-D','-',url,'-H','Host: '+host],stderr=subprocess.STDOUT,timeout=10).decode(errors='replace')
        first='\n'.join(out.split('\n')[:15])
        print('===',url,host,'===')
        print(first[:600])
    except Exception as e:
        print('===',url,host,'=== EXC',e)
print('=== nginx.conf lines 25-45 ===')
try:
    lines=open('/etc/nginx/nginx.conf').read().split('\n')
    for i in range(24,45): print(i+1, lines[i])
except Exception as e: print(e)
