推荐学习书目
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
jun4rui
V2EX  ›  Python

Nginx+Python 怎么搞才好?

  •  
  •   jun4rui · Apr 29, 2015 · 8656 views
    This topic created in 4066 days ago, the information mentioned may be changed or developed.

    原来项目是一个很差的Tomcat+java的框架,准备前后端分离,后端只提供JSON接口,前段纯走js怕影响SEO,所以用主要内容用Python(Django)渲染生成页面。

    准备服务器用Nginx反向代理原来的Tomcat,然后Python怎么和Nginx搭配才好?求一个直观、大众、稳定的好方案。

    15 replies    2015-05-02 23:18:02 +08:00
    Livid
        1
    Livid  
    MOD
    PRO
       Apr 29, 2015   ❤️ 1
    你的 Tomcat 和 Python 应用是运行在不同端口上的,对于 Nginx 来说,就是两个不同的 upstream。在 Nginx 这边你可以把它们配到两个不同的域名上,或者也可以是同一个域名的不同目录回源不同的 upstream。
    hcymk2
        2
    hcymk2  
       Apr 29, 2015
    Nginx 反代 tomcat 在这个项目中意义何在?
    jun4rui
        3
    jun4rui  
    OP
       Apr 29, 2015
    @hcymk2 原来的系统怕换个端口域名就会有问题,先挂着,一步步替换掉
    lujiajing1126
        4
    lujiajing1126  
       Apr 30, 2015   ❤️ 1
    uwsgi做中间层
    fburst
        5
    fburst  
       Apr 30, 2015   ❤️ 1
    一楼的方案是对的。
    不知道楼主对nginx熟悉程度怎么样。我再稍微补充下具体些的东西。
    python一般用gunicorn或uwsgi和nginx对接。具体文档网上一搜一堆。优劣不好说。
    一些坑,自填
    1.ulimit里的配置
    2.net.core.somaxconn
    3.uwsgi listen queue
    jun4rui
        6
    jun4rui  
    OP
       Apr 30, 2015
    @fburst 很感谢,就是需要这个。以前用过Apache,这几年没做过类似工作,Nginx只用过最简单的方面
    lnehe
        7
    lnehe  
       Apr 30, 2015   ❤️ 1
    Nginx+uwsgi+Python
    clino
        8
    clino  
       Apr 30, 2015 via Android   ❤️ 1
    我也都是用uwsgi做应用服务器
    有时候用gevent方式跑
    jjx
        9
    jjx  
       Apr 30, 2015   ❤️ 1
    nginx + bottle(gevent)
    recall704
        10
    recall704  
       Apr 30, 2015   ❤️ 1
    http://www.cnblogs.com/tk091/p/3859514.html
    django 部署,gunicorn、virtualenv、nginx
    我自己写的,你可以看看。
    clino
        12
    clino  
       Apr 30, 2015
    @hcymk2 以前碰到个用root直接跑tomcat的,被我鄙视死,后来有问题有些路径要另外配置反代之类的还要到防火墙上去做
    tomcat再好能做得像nginx那么强大?
    jun4rui
        13
    jun4rui  
    OP
       Apr 30, 2015
    @Livid
    @fburst
    @recall704
    @CharlieTian

    如果架设好nginx反向代理了原来的tomcat和新搭建的Django,要是想打通两者之间的session和cookies的话,请问要去了解什么方面的资料?求关键词
    paulw54jrn
        14
    paulw54jrn  
       Apr 30, 2015
    可以试下Nginx反代uWSGI
    fburst
        15
    fburst  
       May 2, 2015
    @jun4rui
    如果session是存内存数据库。tomcat和python分别连接数据库就好了。读写格式保证一致。

    没有实施过,猜的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5523 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 06:45 · PVG 14:45 · LAX 23:45 · JFK 02:45
    ♥ Do have faith in what you're doing.