Nginx搭建Startpage镜像

之前写过一篇Nginx搭建Google镜像的教程,无奈Google已不是当年那个Google了,索性换成了Startpage镜像,Startpage搜索引擎后台使用Google搜索结果的同时,更注重隐私保护,同时也去除了Google附带的臃肿功能。

Nginx搭建Google镜像

经过测试后发觉使用体验极佳,网络上基本搜索不到搭建Startpage镜像相关的资料,因此写了这篇教程,请不要拿去作恶。

Nginx的编译参数可以参考之前写的Google教程,主要给出Nginx配置文件:

server {
        listen 80;
        listen 443 ssl http2 reuseport;
        server_name so.apad.pro;

        resolver                    8.8.8.8 1.1.1.1 valid=300s;
        resolver_timeout            5s;
        ssl_stapling                on;
        ssl_stapling_verify         on; 
        ssl_trusted_certificate     /data0/htdocs/ssl/origin_ca_rsa_root.pem;
        ssl_certificate             /data0/htdocs/ssl/so.apad.pro.pem;
        ssl_certificate_key         /data0/htdocs/ssl/so.apad.pro.key;
        ssl_session_timeout         1440m;
        ssl_session_cache           shared:SSL:10m;
        ssl_protocols               TLSv1.2;
        ssl_prefer_server_ciphers   on;
        ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA;

        add_header Strict-Transport-Security "max-age=15768000";

        access_log  "pipe:rollback /data1/logs/startpage.log interval=1d baknum=30 maxsize=1G" https buffer=64k flush=5s;

        brotli            on;
        brotli_comp_level 6;
        brotli_static     on;
        brotli_min_length 1k;
        brotli_types      text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml text/javascript application/javascript application/x-javascript text/x-json application/json application/x-web-app-manifest+json text/css text/plain text/x-component font/eot font/opentype font/otf font/truetype font/ttf application/x-font-ttf application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype image/x-icon image/x-win-bitmap;

        location / {
            proxy_redirect off;
            proxy_cookie_domain startpage.com so.apad.pro;
            proxy_pass https://www.startpage.com;
            proxy_connect_timeout 60s;
            proxy_read_timeout 600s;
            proxy_send_timeout 600s;
            proxy_set_header Host "www.startpage.com";
            proxy_set_header Referer https://www.startpage.com;
            proxy_set_header Accept-Encoding ""; 
            proxy_set_header X-Real-IP $remote_addr; 
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header User-Agent $http_user_agent;
            proxy_set_header Accept-Language "en-US";
            proxy_set_header Cookie "preferences=date_timeEEEworldN1Ndisable_family_filterEEE1N1Ndisable_open_in_new_windowEEE0N1Nenable_post_methodEEE1N1Nenable_proxy_safety_suggestEEE1N1Nenable_stay_controlEEE0N1Ninstant_answersEEE1N1Nlang_homepageEEEs%2Fdefault%2Fen%2FN1NlanguageEEEjiantizhongwenN1Nlanguage_uiEEEenglishN1Nnum_of_resultsEEE20N1Nsearch_results_regionEEEallN1NsuggestionsEEE1N1Nwt_unitEEEcelsius";
            sub_filter www.startpage.com so.apad.pro;
            sub_filter '<div class="w-gl__anonymous-view-icon">' '<div style="display:none">';
            sub_filter '<div class="w-gl__anonymous-view-mobile-container anonymous-link">' '<div style="display:none">';
            sub_filter 'class="anonymous-view-url"' 'class="anonymous-view-url" style="display:none"';
            sub_filter_once off; 
            sub_filter_types *;
        }

        if ($server_port = 80 ) {
            return 301 https://$host$request_uri;
        }

        if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot"){
            return 403;
        }

        location /robots.txt {
            add_header Content-Type text/plain;
            return 200 "User-agent: *\nDisallow: /\n";
            log_not_found off;
        }

        if ( $host != $server_name ) {
            return 403;
        }
}

将配置文件中的so.apad.pro替换为自己的域名即可。