GithubHelp home page GithubHelp logo

dailytimes / ngx_http_google_filter_module Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cuber/ngx_http_google_filter_module

0.0 2.0 0.0 112 KB

Nginx Module for Google Mirror

License: GNU General Public License v2.0

C 97.24% Objective-C 2.76%

ngx_http_google_filter_module's Introduction

Nginx Module for Google

Build Status

Description

ngx_http_google_filter_module is a filter module which makes google mirror much easier to deploy.
Regular expressions, uri locations and other complex configurations have been built-in already.
The native nginx module ensure the efficiency of handling cookies, gstatic scoures and redirections.
Let's see how easy it is to setup a google mirror.

location / {
  google on;
}

What? Are you kidding me?
Yes, it's just that simple!

Demo site https://wen.lu

Demo Site

Dependency

  1. pcre regular expression support
  2. ngx_http_proxy_module backend proxy support
  3. ngx_http_substitutions_filter_module mutiple substitutions support

Installation

Download sources first
#
# download the newest source
# @see http://nginx.org/en/download.html
#
wget http://nginx.org/download/nginx-1.7.8.tar.gz

#
# clone ngx_http_google_filter_module
# @see https://github.com/cuber/ngx_http_google_filter_module
#
git clone https://github.com/cuber/ngx_http_google_filter_module

#
# clone ngx_http_substitutions_filter_module
# @see https://github.com/yaoweibin/ngx_http_substitutions_filter_module
#
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
Brand new installation
#
# configure nginx customly
# replace </path/to/> to your real path
#
./configure \
  <your configuration> \
  --add-module=</path/to/>ngx_http_google_filter_module \
  --add-module=</path/to/>ngx_http_substitutions_filter_module
Migrate from existed distribution
#
# get the configuration of existed nginx
# replace </path/to/> to your real path
#
</path/to/>nginx -V
> nginx version: nginx/ <version>
> built by gcc 4.x.x
> configure arguments: <configuration>

#
# download the same version of nginx source
# @see http://nginx.org/en/download.html
# replace <version> to your nginx version
#
wget http://nginx.org/download/nginx-<version>.tar.gz
  
#
# configure nginx
# replace <configuration> to your nginx configuration
# replace </path/to/> to your real path
#
./configure \
  <configuration> \
  --add-module=</path/to/>ngx_http_google_filter_module \
  --add-module=</path/to/>ngx_http_substitutions_filter_module
#
# if some libraries were missing, you should install them with the package manager
#   eg. apt-get, pacman, yum ...
#

Usage

Basic Configuration

resolver is needed to resolve domains.

server {
  # ... part of server configuration
  resolver 8.8.8.8;
  location / {
    google on;
  }
  # ...
}
Google Scholar

google_scholar depends on google, so google_scholar cannot be used independently.
Nowadays google scholar has migrate from http to https, and ncr is supported, so the tld of google scholar is no more needed.
Configuration nginx.

location / {
  google on;
  google_scholar on;
}
Google Language

The default language can be set throuth google_language, if it is not setup, zh-CN will be the default language.

location / {
  google on;
  google_scholar "scholar.google.co.jp";
  # set language to German
  google_language "de"; 
}

Supported languages are listed below.

de en es es-419 fr hr it nl pl pt-BR pt-PT 
vi tr ru ar th ko zh-CN zh-TW ja
Spider Allowance

The spider of any search engines are now allowed to crawl google mirror.
Default robots.txt listed below was build-in aleady.

User-agent: *
Disallow: /

If google_robots_allow set to on, the robots.txt will be replaced with the version of google itself.

  #...
  location / {
    google on;
    google_robots_allow on;
  }
  #...
Upstreaming

upstream can help you to avoid name resolving cost, decrease the possibility of google robot detection and proxy throuth some specific servers.

upstream www.google.com {
  server 173.194.38.1:443;
  server 173.194.38.2:443;
  server 173.194.38.3:443;
  server 173.194.38.4:443;
}
Proxy Protocal

In default, the proxy will use https to communicate with backend servers.
You can use google_ssl_off to force some domains fall back to http protocal.
It is useful, if you want to proxy some domains through another gateway without ssl certificate.

#
# eg. 
# i want to proxy the domain 'www.google.com' like this
# vps(hk) -> vps(us) -> google
#

#
# configuration of vps(hk)
#
server {
  # ...
  location / {
    google on;
    google_ssl_off "www.google.com";
  }
  # ...
}

upstream www.google.com {
  server < ip of vps(hk) >:80;
}

#
# configuration of vps(us)
#
server {
  listen 80;
  server_name www.google.com;
  # ...
  location / {
    proxy_pass https://www.google.com;
  }
  # ...
}

Copyright & License

All codes are under GPLv2
Copyright (C) 2014 by Cube.

ngx_http_google_filter_module's People

Contributors

cuber avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.