推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
monway
V2EX  ›  Python

请教大佬们关于使用 Python 在服务器上拦截请求的问题

  •  
  •   monway · Jan 31, 2018 · 4019 views
    This topic created in 3159 days ago, the information mentioned may be changed or developed.

    想实现的是: 服务器上安装的是 Nginx 或 Apache 提供 web 服务,我想在服务器上执行一个 Python 的脚本拦截用户请求的 Http 数据包。然后修改在发给容器,容器在返回给客户。请问大佬们 Python 可以实现吗?

    8 replies  •  2018-02-04 03:52:33 +08:00
    ysc3839
        1
    ysc3839  
       Jan 31, 2018
    可以,就是个反向代理
    cloverstd
        2
    cloverstd  
       Jan 31, 2018
    1. 用你的 Python 脚本替换 Nginx
    2. Nginx 到你的 Python 脚本,你的脚本再到后端服务
    3. 如果不能动 Nginx 可以用 iptables 实现 1
    owenliang
        3
    owenliang  
       Jan 31, 2018
    做个代理服务倒是可以,想不侵入的拦截是不容易实现的。
    bfpiaoran
        4
    bfpiaoran  
       Jan 31, 2018 via Android
    用 mitmproxy
    0ZXYDDu796nVCFxq
        5
    0ZXYDDu796nVCFxq  
       Jan 31, 2018 via iPhone
    性能很感人,最好先评估一下流量
    edsion996
        6
    edsion996  
       Jan 31, 2018
    用 verynginx 试试?需求不是特别复杂的话,也许并不需要 python。。。
    knightdf
        7
    knightdf  
       Jan 31, 2018
    你需要 nginx-lua
    fakepoet
        8
    fakepoet  
       Feb 4, 2018
    感觉你需要这个 http://openresty.org/cn/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2302 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 00:52 · PVG 08:52 · LAX 17:52 · JFK 20:52
    ♥ Do have faith in what you're doing.