Analysis of the process of implementing Nginx+Tomcat cluster under Windwos

Analysis of the process of implementing Nginx+Tomcat cluster under Windwos

Introduction:

Nginx (pronounced the same as engine x) is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server released under a BSD-like protocol. Developed by Russian programmer Igor Sysoev, it is used by Russia's large portal website and search engine Rambler (Russian: Рамблер). Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx's concurrency capabilities are indeed better than those of the same type of web servers. Users of nginx websites in mainland China include: Sina, NetEase, Tencent, etc.

download:

Tomcat still uses version 6.0. For configuration, refer to the link below this article

Nginx download address: http://nginx.org/

Install:

  • Create a new server folder in the C drive, and then use tomcat to create a running node tomcat-node1
  • Unzip the concurrently downloaded nginx-1.7.1.zip to the server and rename it to nginx
  • Start tomcat to ensure normal access. Here I set the tomcat running port to 10001
  • Double-click nginx.exe to run nginx. You can check whether it is running by visiting http://localhost

Related commands:

  • start nginx
  • nginx -s stop quickly shuts down Nginx, may not save relevant information, and quickly terminates the web service
  • nginx -s quit Shut down Nginx smoothly, save relevant information, and terminate the web service in an organized manner
  • nginx -s reload Reload because Nginx related configuration has been changed and needs to be reloaded
  • nginx -s reopen to reopen the log file

Configuration:

In order to test the integration, the simplest configuration is used here to forward all requests.

#Number of working child processes (usually equal to the number of CPUs or twice the number of CPUs)
worker_processes 1;
#Error log storage path [ debug | info | notice | warn | error | crit ]
error_log logs/error.log info;
#Specify the pid storage file pid logs/nginx.pid;
events {
	#Use network IO model Linux recommends epoll, FreeBSD recommends kqueue, and window does not specify #use epoll;
  worker_connections 1024; #maximum number of connections allowed}
http {
  include mime.types;
  default_type application/octet-stream;
  keepalive_timeout 65;
  gzip on;
	upstream mysvr { # Node list server localhost:10001 weight=5;
	}
  server {
    listen 8008;
    server_name localhost;
    charset UTF-8;
    location / { # All requests are forwarded to this defined node root /ROOT; # Define the default website root directory location of the server index index.html index.htm index.jsp; # Define the name of the homepage index file proxy_pass http://mysvr; # Request to redirect to the server list defined by mysvr}
  }
}

The key is to define the node list and then configure the forwarding processing of the request path

Deploy any test project on tomcat, and then access it through nginx port + project

For ease of use, two bat scripts are written to start and shut down the service

start.bat

@echo off
echo Starting core services begins......
E:
cd E:\service\nginx
start nginx
echo Core service started successfully......
pause
exit

stop.bat

@echo off
echo Core services are starting to shut down...
E:
cd E:\service\nginx
nginx -s stop
echo The core service has been shut down...
pause
exit

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • A brief discussion on two current limiting methods in Nginx
  • Detailed explanation of how to use Nginx + consul + upsync to achieve dynamic load balancing
  • Detailed tutorial on configuring nginx for https encrypted access
  • How to view nginx configuration file path and resource file path
  • The advantages and disadvantages of nginx and lvs and their suitable usage environment
  • Configuration operations of different projects in the secondary directory after nginx configures the domain name

<<:  Mysql implements three functions for field splicing

>>:  Detailed explanation of the visualization component using Vue to compare the differences between two sets of data

Recommend

Examples of importing and exporting MySQL table data

This article describes the import and export oper...

How to configure virtual user login in vsftpd

yum install vsftpd [root@localhost etc]# yum -y i...

Summary of common commands for Linux user and group management

This article summarizes the common commands for L...

How to find and delete duplicate records in MySQL

Hello everyone, I am Tony, a teacher who only tal...

MySQL 5.6.36 Windows x64 version installation tutorial detailed

1. Target environment Windows 7 64-bit 2. Materia...

Comparison between Redis and Memcache and how to choose

I've been using redis recently and I find it ...

Vue implements a simple shopping cart example

This article shares the specific code of Vue to i...

HTML+CSS implementation code for rounded rectangle

I was bored and suddenly thought of the implementa...

CSS3 custom scroll bar style::webkit-scrollbar sample code detailed explanation

The default scroll bar style in Windows is ugly, ...

How to write configuration files and use MyBatis simply

How to write configuration files and use MyBatis ...

Analysis of 2 Token Reasons and Sample Code in Web Project Development

Table of contents question: There are 2 tokens in...

Pure CSS3 code to implement a running clock

Operation effectCode Implementation html <div ...

Example code for implementing auto-increment sequence in mysql

1. Create a sequence table CREATE TABLE `sequence...

How to run py files directly in linux

1. First create the file (cd to the directory whe...

Summary of webpack's mobile adaptation solution

Table of contents rem vw Adapt to third-party UI ...