Ubuntu 14.04 uses Nginx anti-proxy Google

Source: Internet
Author: User
Tags ftp http redirect openssl openssl version git clone


1. Install related software

#
# Install gcc & git
Apt-get install build-essential git gcc g ++ make

# Download the latest Nginx source code
# Http://nginx.org/en/download.html
Wget http://nginx.org/download/nginx-1.9.2.tar.gz"

# Download the latest version of pcre
# Http://www.pcre.org/
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz"

# Download the latest openssl version
# Https://www.openssl.org/
Wget https://www.openssl.org/source/openssl-1.0.2c.tar.gz"

# Download the latest zlib version
# Http://www.zlib.net/

Wget http://zlib.net/zlib-1.2.8.tar.gz"

# Download this extension
Git clone https://github.com/cuber/ngx_http_google_filter_module

# Download the substitutions extension
Git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module

# Decompress
Tar xzvf nginx-1.9.2.tar.gz
Tar xzvf pcre-8.36.tar.gz
Tar xzvf openssl-1.0.2c.tar.gz
Tar xzvf zlib-1.2.8.tar.gz


# Go to the nginx Source Code Directory
Cd nginx-1.9.2

# Set compilation options

./Configure \
-- Prefix =/opt/nginx-1.9.2 \
-- With-pcre = ../pcre-8.36 \
-- With-openssl = ../openssl-1.0.2c \
-- With-zlib = ../zlib-1.2.8 \
With-http_ssl_module \
-- Add-module = ../ngx_http_google_filter_module \
-- Add-module = ../ngx_http_substitutions_filter_module

Make
Sudo make install

# Start Nginx
Sudo/opt/nginx-1.9.2/sbin/nginx
2. Configure Nginx

Edit/opt/nginx-1.9.2/conf/nginx. conf

My configuration is as follows. The red part is the content modified/appended to the default configuration.

# User nobody;
Worker_processes 1;

# Error_log logs/error. log;
# Error_log logs/error. log notice;
# Error_log logs/error. log info;

# Pid logs/nginx. pid;


Events {
Worker_connections 1024;
}


Http {
Include mime. types;
Default_type application/octet-stream;

# Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
# '$ Status $ body_bytes_sent "$ http_referer "'
# '"$ Http_user_agent" "$ http_x_forwarded_for "';

# Access_log logs/access. log main;

Sendfile on;
# Tcp_nopush on;

# Keepalive_timeout 0;
Keepalive_timeout 65;

# Gzip on;

Server {
# Force http redirect to https
Listen 80;
Server_name domain name;
Rewrite ^/(. *) https: // domain name/$1 permanent;
}

Server {
Listen 443;
Server_name domain name;

Ssl on;
Ssl_certificate certificate. crt path;
Ssl_certificate_key certificate. key path;

Resolver 8.8.8.8;
# Charset KOI8-R;

# Access_log logs/host. access. log main;

Location /{
# It is important to add academic support for Google and Google!
Google on;
Google_scholar on;
        }

# Error_page 404/404 .html;

# Redirect server error pages to the static page/50x.html
        #
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
        }
}

}
At last, reload the Nginx configuration to see the Google page.

/Opt/nginx-1.9.2/sbin/nginx-s reload

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.