nginx 下安裝nginx_concat_module報400錯誤

nginx安裝concat模塊可以合併js,css等靜態資源,減少http請求

在nginx源碼目錄執行命令:

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_spdy_module --with-http_gzip_static_module --with-http_sub_module --add-module=../nginx-http-concat

make && make install

編譯成功後還要注意合併js時的400 Bad Request錯誤

由於Nginx在新版本中,使用了標準的 MIME-Type:application/javascript。而在nginx_concat_module模塊目前版本的代碼中,寫的是 application/x-javascript 的類型

修改 nginx-http-concat/ngx_http_concat_module.c

把 x-javascript 改爲 javascript

重新編譯nginx即可

nginx_concat_module下載地址:

https://github.com/alibaba/nginx-http-concat

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章