Nginx Installation and Reverse proxy configuration
N Ginx installation requires some preparatory work. Installing GCC, etc.
Yum-y install make zlib zlib-devel gcc-c++ libtool OpenSSL openssl-devel
also need to install Pcre,pcre (perl Compatible Regular Expressions) is a Perl library that includes Perl a compatible regular expression library.
Yum-y Install Pcre
Download Nginx Source package, here choose is 1.7.8 version. and unzip, and compile
wget Http://nginx.org/download/nginx-1.7.8.tar.gztar zxcf nginx-1.7.8.tar.gz./configure--prefix=/usr/local/nginx- -with-pcre//--prefix= indicates installed path make && make install
After the compilation succeeds, go to the Nginx directory to view the next version and verify that the installation is complete.
[[email protected] ~]# cd /usr/local/nginx/sbin/[[email protected] sbin]#/usr/ local/nginx/sbin/nginx //Start nginx[[email protected] sbin]# ./nginx -v //Verify the Nginx version Nginx version: nginx/1.7.8[[email protected] sbin]# ps aux|grep nginx //viewing the Nginx boot process root 4684 0.0 0.0 103256 840 pts/1 S+ 15:14 0:00 grep nginxroot 32670 0.0 0.0 24304 700 ? ss dec23 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/ local/nginx/conf/nginx.confnobody 32671 0.0 0.0 26804 3824 ? S Dec23 0:00 nginx: worker process nobody 32672 0.0 0.0 26748 3396 ? s dec23 0:16 nginx: worker process
[[email protected] ~] #cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/ nginx.conf.bak //Backup of the master profile [[email protected] ~] #vim /usr/local/nginx/conf/nginx.conf //this will empty the original configuration file and replace the new configuration file. User nobody nobody;worker_processes 2;error_log /usr/local/nginx/logs/nginx_error.log crit;pid /usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 51200;events{ use epoll; worker_connections 6000;} http{ include mime.types; default_type application/ Octet-stream; server_names_hash_bucket_size 3526; server_ names_hash_max_size 4096; log_format combined_realip ' $remote _addr $http _x_forwarded_for [$time _local] ' ' $host ' $request _uri ' $status ' ' " $http _referer " " $http _user_agent "'; sendfile on; tcp_ Nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k; request_pool_ Size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_ size 256k; client_body_temp_path /usr/local/nginx/client_body_temp; proxy_temp_path /usr/local/nginx/proxy_temp; fastcgi_temp_path /usr/local/nginx/fasTcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on ; gzip on; gzip_min_length 1k; Gzip_buffers 4 8k; gzip_comp_level 5; gzip_http_ version 1.1; gzip_types text/plain application/x-javascript text/ css text/htm application/xml; }
Will restart the Nginx, will kill the nginx process can be
Configuring the Reverse Proxy
Access the ports of different Web servers via Nginx
such as: localhost:9080 = 10.1.1.78:9080
In the configuration file join
server { listen 9080; Port server_ for //agent name localhost; //the information of this machine location / { proxy_pass http://10.1.1.78:9080/; //represents the address of the agent proxy_set_ header host $host; proxy_set_header X-Real-IP $remote _addr; proxy_set_ Header x-forwarded-for&nBSP; $proxy _add_x_forwarded_for; }# access_log /home/logs/bb_access.log combined;}
After configuration, restart the nginx. After the test.
[Email protected] sbin]# curl-i http://localhost:9080HTTP/1.1 okserver:nginx/1.7.8date:mon, Dec 07:52:37 G Mtcontent-type:text/htmlcontent-length:1812connection:keep-alivelast-modified:tue, June 01:53:30 GMTETag: " 714-53533459b292a "Accept-ranges:bytes
The test was successful, indicating that the Web site was properly accessible.
This article is from the "first. com" blog, make sure to keep this source http://jimac.blog.51cto.com/401206/1886223
Nginx Installation and Reverse proxy configuration