#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True) CMD = r""" set +e # reproduce nginx-like headers against Next curl -sS -m 10 -o /tmp/out.json -w 'code=%{http_code}\n' \ -H 'Host: nomadro.com' \ -H 'X-Forwarded-For: 8.8.8.8' \ -H 'X-Forwarded-Proto: https' \ -H 'X-Forwarded-Host: nomadro.com' \ -H 'Connection: close' \ -H 'Accept-Encoding: gzip' \ http://127.0.0.1:4003/api/work/v1/boards head -c 200 /tmp/out.json; echo # nginx https again curl -sk -m 10 -o /tmp/out2.json -w 'nginx=%{http_code}\n' -H 'Host: nomadro.com' https://127.0.0.1/api/work/v1/boards head -c 200 /tmp/out2.json; echo # show location / proxy block grep -n 'location /\|proxy_pass.*4003\|proxy_set_header' /etc/nginx/sites-enabled/nomadro.com.conf | head -80 # work-mf snippet cat /etc/nginx/snippets/nomadro-work-mf.conf """ c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False) _, o, e = c.exec_command(CMD, timeout=45) print(o.read().decode()) err = e.read().decode() if err.strip(): print("STDERR", err[-800:]) c.close()