loading

运维

WP-China-Yes自建WordPress仓库源

宝塔服务器面板¥3188大礼包,请点击领取!

WordPressCDN2019年被国内攻击后(存疑),一直屏蔽了大陆IP的访问流量,从大陆访问WP的服务都会返回429 Too Many Requests。虽然WP官方社区并不承认屏蔽了大陆地区的访问(相关链接),但是事实上包括更新、插件、主题等服务一直处于不可用的状态。另外即使抛开屏蔽的问题,AutomatticCDN到国内依然是比较缓慢的。WP-China-Yes自建Wordpress仓库源

使用WP-China-Yes插件反向代理方案,如果担心他人的源不干净,我们可以为自己创建专用仓库源,下面来简单介绍一下需要注意的部分。

需要反代的地址表

序号 官方地址 反代地址 描述
api.wordpress.org apiworg.cn.wp.net API请求地址
downloads.wordpress.org dl-wp-org.cn.wp.net 下载地址
developer.wordpress.org dev-wp-org.cn.wp.net 开发者API
profiles.wordpress.org pf-wp-org.cn.wp.net
ps.w.org psworg.cn.lty.wp.net 插件页静态资源
s.w.org sworg.cn.lty.wp.net 静态资源
ts.w.org tsworg.cn.lty.wp.net 主题页静态资源
wordpress.org wp-org.cn.wp.net 官网
wp-themes.com wp-themes.cn.wp.net 主题官网
secure.gravatar.com grv.wp.net 头像

nginx反代配置

WordPressAPI反代,供服务器向WP的请求,可以不用套CDN。其中涉及到一个跳转(有没有都一样)和8个文本替换,其中替换成的链接请自己想好,后面都要对应的搭建反代。

1、api.wordpress.org

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://api.wordpress.org;
    proxy_set_header Host api.wordpress.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_redirect   https://developer.wordpress.org https://dev-wp-org.cn.lty.fun;
    
    gzip off;
    sub_filter                 ps.w.org                 psworg.cn.ixmu.net;
    sub_filter                 downloads.wordpress.org  dl-wp-org.cn.ixmu.net;
    sub_filter                 profiles.wordpress.org   pf-wp-org.cn.ixmu.net;
    sub_filter                 secure.gravatar.com      grv.ixmu.net;
    sub_filter                 ts.w.org                 tsworg.cn.ixmu.net;
    sub_filter                 wp-themes.com            wp-themes.cn.ixmu.net;
    sub_filter                 s.w.org                  sworg.cn.ixmu.net;
    sub_filter                 wordpress.org            wp-org.cn.ixmu.net;
    sub_filter_last_modified   on;
    sub_filter_once            off;
    sub_filter_types           application/json;
    
}
#PROXY-END/

2、downloads.wordpress.org

WordPress的下载地址,用于服务器下载软件包,可以不套CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://downloads.wordpress.org;
    proxy_set_header Host downloads.wordpress.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;    
}
#PROXY-END/

3、developer.wordpress.org

WP开发者API相关的,用于服务器请求API,可以不套CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://developer.wordpress.org;
    proxy_set_header Host developer.wordpress.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    gzip off;
    sub_filter                 developer.wordpress.org dev-wp-org.cn.ixmu.net;
    sub_filter                 ps.w.org                psworg.cn.ixmu.net;
    sub_filter                 downloads.wordpress.org dl-wp-org.cn.ixmu.net;
    sub_filter_last_modified   on;
    sub_filter_once            off;
}
#PROXY-END/

4、profiles.wordpress.org

不太清楚是干啥的,没看到前端加载,应该用不着套CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://profiles.wordpress.org;
    proxy_set_header Host profiles.wordpress.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
}
#PROXY-END/

5、ps.w.org

插件页静态文件(Plugin Ststaic),用于前端加载,建议使用CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://ps.w.org;
    proxy_set_header Host ps.w.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;    
}
#PROXY-END/

6、s.w.org

静态资源,用于前端加载,建议使用CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://s.w.org;
    proxy_set_header Host s.w.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
}
#PROXY-END/

7、ts.w.org

主题页静态资源(Theme Static),用于前端加载,建议使用CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://ts.w.org;
    proxy_set_header Host ts.w.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;    
}
#PROXY-END/

8、wordpress.org

WP官网,意义不明,前端没看到有从这里加载文件,可以不套CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://wordpress.org;
    proxy_set_header Host wordpress.org;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    gzip off;
    sub_filter                 s.w.org                 sworg.cn.ixmu.net;
    sub_filter                 //wordpress.org         //wp-org.cn.ixmu.net;
    sub_filter                 downloads.wordpress.org dl-wp-org.cn.ixmu.net;
    sub_filter_last_modified   on;
    sub_filter_once            off;
}
#PROXY-END/

9、wp-themes.com

WP主题的链接,暂时也没发现有前端从这里加载,可以不套CDN

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://wp-themes.com;
    proxy_set_header Host wp-themes.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    proxy_redirect        https://wp-themes.com https://wp-themes.cn.ixmu.net;
    
    gzip off;
    sub_filter                 wp-themes.com wp-themes.cn.ixmu.net;
    sub_filter_last_modified   on;
    sub_filter_once            off;
}
#PROXY-END/

10.secure.gravatar.com

用于前端Gravatar头像的加载,建议使用CDN缓存。我之前做过反代这次就没有再搭建,对于其他前端的链接如果主题没有指定只需要修改/wp-includes/link-template.php即可。

#PROXY-START/
proxy_set_header Accept-Encoding "";
location /
{
    proxy_pass https://secure.gravatar.com;
    proxy_set_header Host secure.gravatar.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
}
#PROXY-END/

API服务器:apiworg.cn.wp.net
下载服务器:dl-wp-org.cn.wp.net
搭建完成后将这两个地址填入到WP-China-Yes插件中,即可完成自定义WordPress中国区仓库源的建设与使用,最后说一下源需要使用国外服务器,推荐香港、新加坡、日本等地理位置较近的vps或者服务器,亦可使用CN2-GIA系列的服务器作为仓库源平台。

(0)

本文由 podipod软库网 作者:Anonymous 发表,转载请注明来源!

关键词:,
全国计算机等级考试题库

热评文章

发表评论