Hi Jeff,
/i am not shure, that this will be run ok.
That was not the full line to call. I had think, that was only something
to change in fcgiwrap.
This was a part from a ZTP .
Here the full python script, which run without changing under apache2
with mod_cgid.
-------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/python3
import os
environ = os.environ
serial = "unknown"
ztp_server = "10.1.8.241"
if "HTTP_X_ARISTA_SERIAL" in environ:
serial = environ["HTTP_X_ARISTA_SERIAL"]
serial = serial.strip()
print("Content-Type: text/plain")
print()
print(f"""#!/usr/bin/Cli -p2
enable
zerotouch script-exec-timeout 18000
copy http://{ztp_server}/ztp/EOS-4.30.1F.swi flash:EOS-4.30.1F.swi
copy http://{ztp_server}/cgi-bin/ztp/create-startup-config.py?{serial}
flash:startup-config
config
boot system flash:EOS-4.30.1F.swi
reload
""")
------------------------------------------------------------------------------------------------------------------------------------
The //create-startup-config.py run correkt, i have it tested with a
manual call. /
/
/Am 27.12.2024 um 22:36 schrieb Jeff Dyke:
Pass {serial} to your proxy from a normal nginx args variable.
location /another_script {
proxy_pass http://server/cgi-bin/another_script.py?
<http://server/cgi-bin/another_script.py?%7Bserial%7D>$args
}
And then you'll likely want to change from environ to the query
string. I would also make this ?serial=foo. As the query params are
converted to a dict/dataclass.
On Fri, Dec 27, 2024 at 4:15 PM Ralf Figge via nginx <nginx@nginx.org>
wrote:
Hello,
i am a newbee from nginx. I need to run a python script via
cgi-bin. I
search for information about python and nginx, and found fcgiwrap und
uwsig.
I test uwsig (as cgi-bin), but there i become only error 502 Gateway
error. fcgiwrap looks like better, But i have 1 problem with it:
Here some code for the sript;
----------------------------
#!/usr/bin/python3
import os
environ = os.environ
serial = "unknown"
serial = environ["SERIAL"]
serial = serial.strip()
...
http://server/cgi-bin/another_script.py?{serial}
<http://server/cgi-bin/another_script.py?%7Bserial%7D>
---------------------------------------------------
My Problem is, that the call "another_script.py" does not have the
parameter "?{serial}". (i make a tcpdump from the interface) Has
somebody any idea, why it doesn´t go with fcgiwrap?
It runs under Debian 12, python 3.12, nginx 1.26.2 .
regards
Ralf
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx