【问题标题】:nginx - run shell/python script on wget requestnginx - 根据 wget 请求运行 shell/python 脚本
【发布时间】:2021-01-22 08:03:01
【问题描述】:

我想在每个 wget 上运行一个 shell/python 脚本到我的 nginx 服务器。

例如,如果我 wget http:///text.txt?example=100

我想调用一个脚本来生成一个名为 text100.txt 的新文件并返回它。

换句话说,我可以将 GET 参数传递给脚本,然后从该脚本返回任意文件,以便 wget 客户端下载它们吗?

谢谢!

【问题讨论】:

    标签: http nginx server wget


    【解决方案1】:

    你问的是cgi-bin

    但是,我不建议使用它;

    • 我建议不要将 shell 脚本完全用于 Web 服务,并且
    • 对于 Python,我建议使用 Web 微框架之一,例如 flask

    【讨论】:

    • 感谢您的回答。我看到 cgi 返回标准输出。在这种情况下,如何从脚本中返回文件的内容?
    • 在shell脚本中,可以使用cat;但是,您很有可能最终会遇到安全漏洞。在 python 中,您可以使用print()sys.stdout.write()。不过,再次使用现代 Web 框架要好得多; cgi-bin 现在几乎只具有历史意义。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-18
    • 2013-07-27
    • 1970-01-01
    • 1970-01-01
    • 2018-06-28
    • 2020-01-01
    相关资源
    最近更新 更多