First step: Download Nginx version of Windows, unzip to use, click Nginx.exe start Nginx
or cmd command
1. Start:
D:\nginx+tomcat\nginx-1.9.3>start Nginx or d:\nginx+tomcat\nginx-1.9.3> Nginx.exe Note: The first is recommended, and the second will keep your cmd window in execution and cannot be manipulated by other commands.
2. Stop:
D:\nginx+tomcat\nginx-1.9.3>nginx.exe-s stop or D:\nginx+tomcat\nginx-1.9.3>nginx.exe-s quit Note: Stop is a quick stop nginx, The information may not be saved; Quit is a complete and orderly stop nginx, and save the relevant information.
3. Re-loading Nginx:
D:\nginx+tomcat\nginx-1.9.3>nginx.exe-s Reload
This command is used when configuration information is modified and needs to be re-loaded in these configurations.
4. Reopen the log file:
D:\nginx+tomcat\nginx-1.9.3>nginx.exe-s Reopen
5. View Nginx Version:
D:\nginx+tomcat\nginx-1.9.3>nginx-v
Nginx default port is 80 direct access to localhost if the show Nginx Welcome page indicates success, this step generally does not appear to be a problem
Step three: Configure a few tomcat, each of which will be server.xml in the 8080,8005,8009 of these places to fix it.
Step three: Modify the nginx.conf (note adding the Red section is possible)
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
Upstream server_lb{#server_lb跟下面的一样
Server localhost:8090; #这里是tomcat的地址
Server localhost:8091;
}
server {
Listen 80;
server_name localhost;
Location/{
root HTML;
Proxy_pass http://server_lb;
Index index.html index.htm INDEX.JSPF index.jsp;
Proxy_redirect default;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
}
Fourth step: Modify the Server.xml profile file in each Tomcat
<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster" jvmroute= "Jvmroute"/>
Note, however, because each Tomcat deploys the same project, if there is data written directly to the session, and not the cookie that is used to store the session key (because the access address uses IP, does not apply to the domain name, therefore cannot use the cookie), will Causes two access session ID inconsistencies. At this point you need to do a session copy or share. The following actions are required:
Fifth step: Session sharing, because the Windows support Tomcat broadcasting mechanism, so just add <distributable/> in WEB.XM, if you need to implement session sharing in Linux this way , Redis can be used in Linux and later will introduce
Through the above steps, we realized the Nginx cluster tomcat in Windows, and realized the session sharing. If you need a video friend, you can find it in a previous article
160512. nginx+ multiple Tomcat cluster +session Sharing (Windows edition)