Nginx ("Engine X") is a high-performance HTTP and reverse proxy server , the following is the Linux CentOS platform installation Nginx and configure the reverse proxy process (using source installation method)
One: Install the compilation environmentGCC g++ and make (for compiling the source code into an executable file)
1yum Install gcc gcc-c++2 yum-y install gcc automake autoconf libtool make
Two: InstallationPcre (nginx rewrite dependent pcre library) zlib (for gzip compression) 1. Install Pcre
Cd/usr/local/srcwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz TAR-ZXVF PCRE-8.34.TAR.GZCD Pcre-8.34./configuremakemake Install
2. Installing zlib
Cd/usr/local/srcwget HTTP://ZLIB.NET/ZLIB-1.2.8.TAR.GZTAR-ZXVF ZLIB-1.2.8.TAR.GZCD Zlib-1.2.8./configuremakemake Install
3. Installing OpenSSL
wget http://www.openssl.org/source/openssl-1.0.1t.tar.gztar-zxvf Openssl-1.0.1t.tar.gz./config Shared--prefix=/ Usr/local--openssldir=/usr/local/ssl make dependmakesudo make install
Three. Installing Nginx
Cd/usr/local/srcwget HTTP://NGINX.ORG/DOWNLOAD/NGINX-1.10.1.TAR.GZTAR-ZXVF NGINX-1.10.1.TAR.GZCD nginx-1.10.1./ Configure--sbin-path=/usr/local/nginx/sbin--conf-path=/usr/local/nginx/conf/nginx.conf--pid-path=/usr/local/ Nginx/nginx.pid--with-http_ssl_module--with-pcre=/usr/local/src/pcre-8.39--with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1tmakemake Installsudo make Install
Note:sbin-path(boot file path)
Conf-path(configuration file path)
Pid-path(pid file, just installed default no, only after the activation of Nginx )
Four: StartNginx
Cd/usr/local/nginx/sbin
1. start the./nginx
2. restart./nginx-s Reload
Five. Configuring the reverse proxy PointingNode (where node listens 127.0.0.1:3000)
Cd/usr/local/nginx/conf
Vim nginx.conf
where the server option is configured as follows
lerver{ Listen; CharSet Utf-8; Location/{ proxy_pass http://127.0.0.1:3000; } }
lerver{
Listen 80;
CharSet Utf-8;
Location/{
Proxy_pass http://127.0.0.1:3000;
}
}
Six. OpenGIZP compression
Under HTTP options
Under HTTP options , gzip on; Gzip_min_length 1k; Gzip_buffers 64k; Gzip_http_version 1.1; Gzip_comp_level 6; Gzip_types application/javascript text/javascript text/plain application/x-javascript text/css application/xml; Gzip_vary on; Note: gzip_types must be added application/javascript otherwise JS will not be compressed
Not to be continued ...
Linux installation Nginx and reverse proxy configuration