KoriIku / luxirty-search

一个搜索引擎,基于 Google,屏蔽内容农场,无广告,无跟踪,干净,简洁,快。
https://search.luxirty.com
GNU Affero General Public License v3.0
1.31k stars 128 forks source link

这个搜索似乎在国内环境用不了 #30

Closed huhaku closed 1 month ago

huhaku commented 1 month ago

看了下,有不少资源是直接使用google的,在国内有墙环境下是用不了的.有很多时候翻墙并不是那么方便 感觉是不是可以在服务器上做下反代去处理掉这些资源

KoriIku commented 1 month ago

可以考虑 whoogle 或者 searxng ,在反代Google方面这些项目更符合需求、也更成熟。

huhaku commented 1 month ago

我之前用的就是searxng,感觉太重了,想找一个轻量化的替代方案. 不过没事,反代的问题我自己解决了,用国外的服务器反代样式有点错位,并且好像会自动跳到TW站去,不过问题不大,调一下就好 感谢你提供了一个那么好的前端

KoriIku commented 1 month ago

我之前用的就是searxng,感觉太重了,想找一个轻量化的替代方案. 不过没事,反代的问题我自己解决了,用国外的服务器反代样式有点错位,并且好像会自动跳到TW站去,不过问题不大,调一下就好 感谢你提供了一个那么好的前端

如果您有时间,是否可以在此分享您的解决方案,此 issue 已置顶,您的分享会对之后有相似问题的朋友有所帮助。(o゚v゚)ノ

huhaku commented 1 month ago

将https://cse.google.com/cse.js?cx=%VITE_GOOGLE_CSE_CX% 替换为 /cse.js?cx=%VITE_GOOGLE_CSE_CX%

下面配置仅供参考

    listen       80;
    listen  [::]:80;
    server_name  localhost;

    access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        try_files $uri $uri/ /index.html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ^~ /cse.js {
        proxy_pass https://cse.google.com;

        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 $scheme;
    }

    location /api/play {
        proxy_pass https://play.google.com;

        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 $scheme;
    }

    location /api/support {
        proxy_pass https://support.google.com;

        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 $scheme;
    }

    location /api/csqr {
        proxy_pass https://csqr-autopush.corp.google.com;

        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 $scheme;
    }

    location /api/csex {
        proxy_pass https://cse.google.com;

        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 $scheme;
    }

    location /api/ads {
        proxy_pass https://www.adsensecustomsearchads.com;

        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 $scheme;
    }

    location /api/developers {
        proxy_pass https://developers.google.com;

        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 $scheme;
    }

    location /api/clients1 {
        proxy_pass https://clients1.google.com;

        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 $scheme;
    }

    # 处理 /api 作为通用代理
    location /api {
        proxy_pass https://www.google.com;

        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 $scheme;
    }

    sub_filter '+zh_TW' '+zh_CN';
    sub_filter '=zh-TW' '=zh-CN';    
    # 处理输出中的 URL 替换
    sub_filter 'https://cse.google.com' '/api';
    sub_filter 'www.google.com' '/api';
    sub_filter '//play.google.com' '/api/play';
    sub_filter '//support.google.com' '/api/support';
    sub_filter '//csqr-autopush.corp.google.com' '/api/csqr';
    sub_filter '//cse.google.com' '/api/csex';
    sub_filter '//www.adsensecustomsearchads.com' '/api/ads';
    sub_filter '//developers.google.com' '/api/developers';

    # 处理搜索api
    sub_filter 'clients1.' '';
    sub_filter 'a.vs' '"/api/clients1"';

    proxy_set_header Accept-Encoding "";
    sub_filter_types text/css application/javascript;
    sub_filter_once off;
}
zhyueyueniao commented 2 weeks ago

这个是直接进docker里用你这个覆盖nginx配置就行了吗

huhaku commented 1 week ago

这个是直接进docker里用你这个覆盖nginx配置就行了吗

对, 不过不是直接覆盖,要根据你自己的需求调整