Chrome翻译完美解决:代理谷歌翻译+hosts

通过反向代理 translate.googleapis.com 并配置 hosts,让 Chrome 翻译恢复正常。

Chrome 内置翻译功能依赖 translate.googleapis.com,在国内无法直接访问。通过在服务器上搭建反向代理并修改 hosts 即可解决。

方案一:sniproxy(推荐)

不需要自签证书,但需独立占用443端口:

Bash
apt-get install -y sniproxy# 在 /etc/sniproxy.conf 的 table https_hosts 部分添加:# translate.googleapis.com$  *sniproxy -c /etc/sniproxy.conf

方案二:nginx + 自签证书

Nginx
server {    listen 443 ssl http2;    server_name translate.googleapis.com;    ssl_certificate /home/translate.googleapis.com.pem;    ssl_certificate_key /home/translate.googleapis.com-key.pem;    location / {        proxy_set_header Host $http_host;        proxy_pass https://translate.googleapis.com;    }}

配置 hosts

在 hosts 文件中添加:

Text
你的服务器IP translate.googleapis.com

验证

浏览器访问 https://translate.googleapis.com/translate_static/css/translateelement.css,能正常加载即表示代理成功。