• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

jquery/codeorigin.jquery.com: jQuery CDN

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

jquery/codeorigin.jquery.com

开源软件地址:

https://github.com/jquery/codeorigin.jquery.com

开源编程语言:

JavaScript 69.4%

开源软件介绍:

codeorigin.jquery.com

Add new assets

To publish a new release, project maintainers should commit new assets to the cdn/ directory and push to the main branch. The jQuery CDN (code.jquery.com) and releases site (releases.jquery.com) will both automatically rebuild.

jQuery CDN

The jQuery CDN assets are served from a static file server (Nginx), provisioned through Docker.

Prerequisites:

Local development

Build the image:

Build the image, by running the following in a clone of this repo:

docker build -t codeorigin ./

Test the container in open mode:

  1. Start a container, exposing port 80:
    docker run --rm -p 4000:80/tcp codeorigin
    
  2. The site is now running at http://localhost:4000/jquery-3.0.0.js. To stop the container, press ctrl+c

Inspect the container:

Run it with a shell entrypoint and set interactive/tty mode by adding the parameters -i -t --entrypoint /bin/sh. Note that when inspecting the container, nginx will not be started.

docker run --rm -p 4000:80/tcp -it --entrypoint /bin/sh codeorigin

# /docker-entrypoint.d/20-envsubst-on-templates.sh 3>&1
...
# cat /etc/nginx/conf.d/default.conf
...

Inspect restricted mode:

docker run --rm -p 4000:80/tcp -e "CDN_ACCESS_KEY=$CDN_ACCESS_KEY" -it --entrypoint /bin/sh codeorigin

Debug nginx:

In cfg/default.conf, change error_log … crit to error_log … debug and then build+run as usual.

Test the container in restricted mode:

There is a restricted mode, which responds to unauthorized static file requests with a redirect instead of serving files.

  1. Run export CDN_ACCESS_KEY="$(openssl rand -hex 32)"
  2. Start a container, exposing port 80, and given the environment variable:
    docker run --rm -p 4000:80/tcp -e "CDN_ACCESS_KEY=$CDN_ACCESS_KEY" codeorigin
    
  3. The site is now running at http://localhost:4000/jquery-3.0.0.js. To stop the container, press ctrl+c

In the restricted mode:

  • Simple requests for static files redirect to code.jquery.com/*, e.g. curl -i 'http://localhost/jquery-3.0.0.js'.
  • Requests with the access key will respond by serving the file: curl -i -H "x-cdn-access: $CDN_ACCESS_KEY" 'http://localhost/jquery-3.0.0.js'
  • Requests with an invalid key will redirect the same as without: curl -i -H "x-cdn-access: wrong" 'http://localhost/jquery-3.0.0.js'

Production deployment

  1. First, generate a CDN access key: openssl rand -hex 32.
  2. At a hosting platform of your choosing, build or pull the container, and pass the CDN access key as run environment variable.
  3. Finally, configure the CDN to use the container address as its origin, with special handling to augment origin pulls with a Host: code.jquery.com header, and a x-cdn-access header with the access key.

In case of emergency

If you need to deploy a standalone codeorigin site immediately, or if there are origin pull failures and you're not sure why, then deploy the container without any CDN_ACCESS_KEY environment variable. The codeorigin container then default to its unrestricted mode (no offload redirects).


WordPress build

This repository is also used to update the asset catalog at https://releases.jquery.com/, which is an auto-generated WordPress site.

To preview changes for a jquery-wp-content instance, follow the workflow instructions from our documentation on contributing to jQuery Foundation web sites.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap