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