Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure tomcat cluster under Nginx reverse proxy in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian introduces in detail "how to configure the tomcat cluster under the Nginx reverse proxy in Linux", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to configure the tomcat cluster under the Nginx reverse proxy in Linux" can help you solve your doubts.

Nginx has the characteristics of reverse proxy (note the difference between forward proxy and forward proxy) and load balancing.

This time nginx is installed on the 192.168.1.108 linux machine. Install nginx first to install openssl library, gcc,pcre,zlib library and so on.

Tomcat is installed on both 192.168.1.168 and 192.168.1.178 machines. The client accesses the project content deployed by tomcat in 192.168.1.168 and 192.168.1.178 by accessing 192.168.1.108 reverse proxy.

Install nginx under 1.linux (machine 192.168.1.108)

Install the opensl library.

Yum install-y openssl openssl-devel

Gcc:yum install gcc-c++ needs to be installed

Install pcre yum install-y pcre pcre-devel

Install the zlib library yum install-y zlib zlib-devel

Download nginx: wget

Installed under / usr/local/

Decompress tar-zxvf nginx-1.13.0.tar.gz

Go to the directory and run. / configure to generate makefile

Makefile is added to the directory at this time.

Compile make

Installation: make install

After completion, there is an extra nginx in the local directory.

Start nginx

Go to the sbin directory and execute. / nginx

View startup results

Window access 192.168.1.108 nginx default port is 80

Close. / nginx-s stop

It is also inaccessible at this time after it is closed.

. / nginx-s reload can reload the configuration file after startup, which is suitable for modifying the configuration file at the startup meeting.

Install tomcat (192.168.1.168 and 192.168.1.178 machines) under 2.linux

The installation process is very simple, not to mention. Install tomcat on the other two linux machines (192.168.1.168 and 192.168.1.178), and randomly deploy a project nginxtest with a content of 1111. One is 22222.

At this time, you are accessing a different ip address and have not yet been configured with nginx to act as a reverse proxy server.

3. Nginx acts as a reverse proxy server

Mainly configure the contents of nginx.conf

a. Configure the server group to add the upstream configuration between http {} nodes.

192.168.1.168 9090 and 192.168.1.178 VR 9191 are the tomcat of the other two linux machines (see above 2)

Upstream lxstest {server 192.168.1.168 server 90; 192.168.1.178VR 9191;}

b. Change the port number of nginx snooping from 80 to 7777 (whatever you want, or not).

Server {listen 7777;.}

c. In location {}, configure the reverse proxy address with proxy_pass; here "http://" is indispensable, and the subsequent address should be consistent with the name defined in the first step upstream." (the above is lxstest, so)

Location / {root html; index index.html index.htm; proxy_pass http://lxstest;}

After the above modification, start the nginx of the 192.168.1.108 machine

Finally, visit a different page from the same address of 192.168.1.108:7777/nginxtest, indicating that one visit is 192.168.1.168, the other is 192.168.1.178

Http://192.168.1.108:7777

Equivalent to =

Equivalent to =

Finally, you will find the corresponding tomcat.

Then find the corresponding nginxtest project.

After reading this, the article "how to configure tomcat clusters under Nginx reverse proxy in Linux" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report