分类
Linux

反代Duden

由于Duden的官方网站上引用了一些被墙的资源,导致Duden访问起来巨慢无比,查词巨不方便。博主便决定用Nginx的“反向代理”功能建立一个Duden的镜像站。

先在Freenom上申请一个免费的顶级域名

为镜像站建立一个目录

sudo mkdir /usr/share/nginx/html/ddproxy

在Nginx配置文件中加入以下代码(镜像站首页):

server {
        listen [::]:443;

        ssl        on;
        ssl_certificate         ssl/ddproxy.cf.pem;
        ssl_certificate_key     ssl/ddproxy.cf.key;

        server_name    ddproxy.cf www.ddproxy.cf;
        access_log     /var/log/nginx/nginx.vhost.access.log;
        error_log      /var/log/nginx/nginx.vhost.error.log;
        location / {
                root   /usr/share/nginx/html/ddproxy;
        }
}

Duden反向代理:

server {
        listen [::]:443 ssl http2;

        ssl        on;
        ssl_certificate         ssl/ddproxy.cf.pem;
        ssl_certificate_key     ssl/ddproxy.cf.key;

        server_name    dictacceleration.ddproxy.cf;
        access_log     /var/log/nginx/nginx.vhost.access.log;
        error_log      /var/log/nginx/nginx.vhost.error.log;
        root   /usr/share/nginx/html/ddproxy;
        location / {
                proxy_redirect https://www.duden.de/ /;
                proxy_cookie_domain duden.de dictacceleration.ddproxy.cf;
                proxy_pass https://www.duden.de;
                proxy_set_header X-Real-IP $realip_remote_addr;
                proxy_set_header X-Forwarded-For $realip_remote_addr;
                proxy_set_header Host "www.duden.de";
                proxy_set_header Accept-Encoding "";
                proxy_set_header User-Agent $http_user_agent;
                proxy_set_header Accept-Language "zh-CN";
                sub_filter www.duden.de dictacceleration.ddproxy.cf;
                sub_filter ajax.googleapis.com ajax.ddproxy.cf;
                sub_filter rs.epoq.de none.ddproxy.cf;
                sub_filter static.site24x7rum.com none.ddproxy.cf;
                sub_filter cdn-a.yieldlove.com none.ddproxy.cf;
                sub_filter d29pb5sqvxbrp8.cloudfront.net none.ddproxy.cf;
                sub_filter_once off;
        }
}

这里用sub_filter替换字符串,并将一部分被墙的非重要资源给导向none.ddproxy.cf这个域名,该域名被解析到127.0.0.1[::1]。以此来变相阻止浏览器加载被墙资源,加速页面加载。

ajax.googleapis.com反代:

server {
        listen [::]:443 ssl http2;

        ssl        on;
        ssl_certificate         ssl/ddproxy.cf.pem;
        ssl_certificate_key     ssl/ddproxy.cf.key;

        server_name    ajax.ddproxy.cf;
        access_log     /var/log/nginx/nginx.vhost.access.log;
        error_log      /var/log/nginx/nginx.vhost.error.log;
        root   /usr/share/nginx/html/ddproxy;
        location / {
                proxy_redirect https://ajax.googleapis.com/ /;
                proxy_cookie_domain ajax.googleapis.com ajax.ddproxy.cf;
                proxy_pass https://ajax.googleapis.com;
                proxy_set_header X-Real-IP $realip_remote_addr;
                proxy_set_header X-Forwarded-For $realip_remote_addr;
                proxy_set_header Host "ajax.googleapis.com";
                proxy_set_header Accept-Encoding "";
                proxy_set_header User-Agent $http_user_agent;
                proxy_set_header Accept-Language "zh-CN";
                sub_filter ajax.googleapis.com ajax.ddproxy.cf;
                sub_filter_once off;
        }
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据