rockq-org / wildfire

Project to publish personal stuffs, a platform alike eBay based wechat.
http://shorterurl.net/pul2zu7
3 stars 1 forks source link

Compress and Publish client static files into CDN #136

Closed hailiang-wang closed 9 years ago

hailiang-wang commented 9 years ago

Description

for the client side, they mostly are static files, css, html and javascript.

Solution

Use qiniu cdn

Use loader module from npm.

https://www.npmjs.com/package/loader

Use index.ejs template to check a config flag.

@gissues:{"order":50,"status":"inprogress"}

hailiang-wang commented 9 years ago

七牛账号,bucket

地址 http://www.qiniu.com/

bucket for wildfire staging - 
https://portal.qiniu.com/bucket/wildfirepro/index

登录名:hailiang.hl.wang@gmail.com 密码:Cawtandewk

上传文件到七牛

使用 qrsync http://developer.qiniu.com/docs/v6/tools/qrsync.html

cd wildfire/client
qrsync production.qiniu.json

production.qiniu.json

{
    "src":          "/root/git/wildfire/public/ionic/www",
    "dest":         "qiniu:access_key=MuDBhibABT6T85B1mA5bqoolYVCmGUizJ2CMS_Wn&secret_key=x3W_dZVS75w6HraQciomlDfn_NC2hqPl4qfB1rF9&bucket=wildfirepro&key_prefix=/",
    "deletable":    0,
    "debug_level":  0
}

压缩文件

grunt compress

修改index html,自动或者手动

将压缩好的js,css脚本的路径都改成七牛的路径
nihgwu commented 9 years ago

T.T

hailiang-wang commented 9 years ago

使用简单的方案

image

hailiang-wang commented 9 years ago

@zqhorse 请充一下值,完成CDN 域名绑定。 thanks.

image

nihgwu commented 9 years ago

是的,这个需要10块钱认证费,开好了绑个域名

hailiang-wang commented 9 years ago

Problem

上面的命令执行结束,文件被影射到这样的路径中。

{
    "src":          "/root/git/wildfire/client/www",
    "dest":         "qiniu:access_key=9MboRdgFktNfebBxO99cVeR6oumOMYeDCkjTH5ek&secret_key=6-zwXgAB3DV2u32eZ6NRN05lgtcXbqOoSM0IGX7i&bucket=wildfire-gges&key_prefix=/",
    "deletable":    0,
    "debug_level":  0
}

-->

http://7xj83h.com2.z0.glb.qiniucdn.com/@/index.html#/tab/index/

问题是,不应该有_@_的!

Solution

将 &key_prefix=/ 去掉 就 变成 http://7xj83h.com2.z0.glb.qiniucdn.com/index.html#/tab/index/

hailiang-wang commented 9 years ago

image

hailiang-wang commented 9 years ago

URLs

http://7xj83h.com2.z0.glb.qiniucdn.com/index.html#/tab/index/

-->

http://wildfire-service.arrking.com/index.html#/tab/index/

hailiang-wang commented 9 years ago

the proxy server received an invalid response

http://stackoverflow.com/questions/9834318/the-proxy-server-received-an-invalid-response-from-an-upstream-server

image

hailiang-wang commented 9 years ago

ProxyBadHeader Ignore

http://blog.somepixels.net/en/502-proxy-error-uploading-from-apache-mod_proxy-to-tomcat-7/

hailiang-wang commented 9 years ago

七牛绑定域名审核 三个工作日内

image