2013-02-24 16 views
3

雖然與龍捲風的工作,我發現的gzip =真正的功能,而在命令行中運行的應用程序,以下設置工作正常:tornadoweb的gzip =真下supervisord和nginx的工作不

define("port", default=settings.LISTEN_PORT, help="run on the given port", type=int) 
define("debug", default=True, help="run in debug mode", type=bool) 
define("dont_optimize_static_content", default=False, 
     help="Don't combine static resources", type=bool) 
define("dont_embed_static_url", default=False, 
     help="Don't put embed the static URL in static_url()", type=bool) 

tornado.options.parse_command_line() 
tornado.options.options['log_file_prefix'].set('/var/log/tmp.log') 

app_settings = dict(
    template_path=os.path.join(os.path.dirname(__file__), "templates"), 
    static_path=os.path.join(os.path.dirname(__file__), "static"), 
    xsrf_cookies=False, 
    gzip=True, 
    debug=True, 
) 

然而,部署應用程序與supervisord/nginx響應從龍捲風服務器不gziped。

[program:app-8001] 
command=python /var/app/server/app.py --port=8001 --logging=debug ----dont_optimize_static_content=False 
directory=/var/app/server/ 
stderr_logfile = /var/log/app-stderr.log 
stderr_logfile_backups=10 
stdout_logfile = /var/log/app-stdout.log 
stdout_logfile_backups=10 
process_name=%(program_name)s 
loglevel=debug 

任何想法我做錯了什麼?

+0

不是我認爲這是你的bug,而是你在supervisor命令中有太多'----'。 – koblas 2013-02-25 02:33:01

+0

對不起,它不是... – user1632928 2013-02-25 07:46:52

回答

1

默認情況下,nginx在向Tornado(或任何其他任何東西)發送請求時不會執行HTTP/1.1請求。龍捲風需要HTTP/1.1支持才能返回gzip的內容。從web.py

def __init__(self, request): 
    self._gzipping = request.supports_http_1_1() and \ 
     "gzip" in request.headers.get("Accept-Encoding", "") 

重要的代碼片段應該是通過添加以下到您的配置文件覆寫投放 - 但它不會對我的實例運行。

proxy_http_version 1.1;