Configure the Nginx as Url_hash forwarding method
Name and version of the software required: pcre-8.02.tar.gz nginx-0.7.58.tar.gz nginx_upstream_hash-0.3.1.tar.gz
1. Installation Pcre
TAR-ZXVF pcre-8.02.tar.gz
cd pcre-8.02/
./configure
2. Install Url_hash patch for Nginx
TAR-ZXVF nginx-0.7.58.tar.gz
tar-zxvf nginx_upstream_hash-0.3.1.tar.gz
cd nginx-0.7.58/
patch-p0 </ Var/tmp/loojoy/nginx_upstream_hash-0.3.1/nginx.patch
3. Installation Nginx
Groupadd www
useradd www-g www
./configure--prefix=/usr/local/webserver/nginx
--user=www
www
--add-module=/var/tmp/loojoy/nginx_upstream_hash-0.3.1
--with-http_ssl_module
--with-http_stub _status_module
4, check the nginx generated configuration file is correct
/usr/local/webserver/nginx/sbin/nginx-t
5, start nginx if nginx.conf check through, then start Nginx.
/usr/local/webserver/nginx/sbin/nginx
6. View Port Netstat-ant
7, through the browser access: http://your_nginx_server_ip/If the normal access, then Nginx installed successfully.
8, modify the Nginx configuration file as follows:
-------------------[s]url_hash forwarding mode nginx.conf[s]--------------------user www www;
Worker_processes 10;
Error_log Logs/error.log;
#error_log Logs/error.log Notice;
#error_log Logs/error.log Info;
#pid Logs/nginx.pid;
Worker_rlimit_nofile 51200;
events {use Epoll;
Worker_connections 51200;
} http {include mime.types;
Default_type Application/octet-stream;
Keepalive_timeout 120;
Tcp_nodelay on;
Upstream your.website.name{server your.tomcat.server.ip1:8080;
Server your.tomcat.server.ip1:8080;
Hash $request _uri;
} server {Listen 80;
server_name your.website.name;
Location/{Proxy_pass http://your.website.name;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; } log_format www_gjw_com ' $remote _addr-$remote _user [$time _local] $request ' $status ' $body _bytes_sent ' $http _referer
"$http _user_agent" "$http _x_forwarded_for";
#access_log/data1/logs/www.log www_gjw_com; LocatIon/nginx_status {stub_status on;
Access_log off;
-------------------[E]url_hash forwarding nginx.conf[e]--------------------
9, add Nginx startup, shutdown, restart script
-------------------[S]url_hash forwarding nginx start, close script [S]--------------------
#!/bin/sh
cwd= ' pwd ' case
$ in
start)
/usr/local/webserver/nginx/sbin/nginx;
;
Stop)
kill-2 ' ps-ef|grep '/usr/local/webserver/nginx/sbin/nginx ' |grep-v ' grep ' |awk ' {print $} '
;;
Restart)
CD "$CMD"
$ stop
$ start
;;
*
echo $ "Usage: $ {Start|stop|restart}"
exit 1
Esac
exit 0
-------------------[e]url_ Hash forwarding mode Nginx start, close script [E]--------------------
Change the file permissions
chmod u+x nginx.sh
starts nginx./nginx.sh start Restart
nginx./nginx.sh Restart
shutdown nginx./nginx.sh stop
nginx_upstream_hash-0.3.1.tar.gz (4.9 kb) Downloads: nginx_upstream_hash-0.3.tar.gz (4.9 kb) Download number of times: 11