nginx and python script

Jeff Dyke jeff.dyke at gmail.com
Fri Dec 27 21:36:17 UTC 2024


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 at 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}
> ---------------------------------------------------
>
> 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 at nginx.org
> https://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20241227/524965bd/attachment.htm>


More information about the nginx mailing list