Nginx reverse proxy and proxy_cache cache build CDN server (1)

Source: Internet
Author: User

Problems:
Mobile users access the web server www.osyunwei.com very slowly
Solution:
1. Place an nginx reverse proxy server in the mobile data center
2. Through intelligent DNS resolution, all mobile users will be resolved to the nginx reverse proxy server when accessing www.osyunwei.com.
3. Use a leased line connection between the nginx reverse proxy server and the web Server

Note:
1. web Server
Line: China Telecom
IP: 192.168.21.129
Domain Name: www.osyunwei.com
2. nginx Reverse Proxy Server
Line: Mobile
System: CentOS 6.2
IP: 192.168.21.164
Vi/etc/hosts # edit and add the following line at the end of the file
192.168.21.129 www.osyunwei.com
3. Client
Line: Mobile
System: Windows 7
IP: 192.168.21.130
C: \ Windows \ System32 \ drivers \ etc \ hosts # open it in notepad and add the following line at the end of the file
192.168.21.164 www.osyunwei.com


################## The following operations are configured on the nginx reverse proxy server ############ #######
1. Disable SELinux

Vi/etc/selinux/config
# SELINUX = enforcing # comment out
# SELINUXTYPE = targeted # comment out
SELINUX = disabled # Add
: Wq save, close.
Shutdown-r now restart the system
2. enable port 80 of the firewall
Vi/etc/sysconfig/iptables
Add the following content
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
/Etc/init. d/iptables restart # restart the firewall to make the configuration take effect.
3. Install the compilation tool
System O & M www.osyunwei.com reminder: qihang01 original content©All rights reserved. For more information, see the source and original link.
Yum install wget make gcc-c ++ zlib-devel openssl-devel pcre-devel gd kernel keyutils patch perl
4. system conventions
Software source code package storage location:/usr/local/src
Source code package compilation and installation location:/usr/local/software name
5. Download Software
Cd/usr/local/src # enter the Directory
1) download the current stable version of nginx)
Wget http://nginx.org/download/nginx-1.0.12.tar.gz
2) download pcre to support nginx pseudo-static)
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
(2) download ngx_cache_purge to clear the specified URL cache)
Wget http://labs.frickle.com/files/ngx_cache_purge-1.5.tar.gz
6. Install pcre
Cd/usr/local/src
Mkdir/usr/local/pcre # create the installation directory
Tar zxvf pcre-8.21.tar.gz
Cd pcre-8.21
./Configure -- prefix =/usr/local/pcre # Configuration
Make
Make install
7. Install nginx
Groupadd www # Add a www Group
Useradd-g www-s/bin/false # create an nginx Running Account www and add it to the www group. www users are not allowed to log on to the system directly.
Cd/usr/local/src
Tar zxvf ngx_cache_purge-1.5.tar.gz
Tar zxvf nginx-1.0.12.tar.gz
Cd nginx-1.0.12
. /Configure -- prefix =/usr/local/nginx -- user = www -- group = www -- with-http_stub_status_module -- with-openssl =/usr/-- with-pcre =/usr/local/src /pcre-8.21 -- add-module = .. ngx_cache_purge-1.5
Note: -- with-pcre =/usr/local/src/pcre-8.21 points to the path of the source package decompression, rather than the installation path, otherwise an error will be reported
Make # compile
Make install # install
/Usr/local/nginx/sbin/nginx # Start nginx
Chown www. www-R/usr/local/nginx/html # Set the directory owner
Chmod 700-R/usr/local/nginx/html # Set Directory Permissions


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.