In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Tomcat+nginx cluster is like, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Main points of content:
First, the principle explanation:
(1) dynamic and static separation
(2) forward proxy and reverse proxy
Second, experimental examples
First, the principle explanation:
(1) dynamic and static separation
In order to improve the response speed of the website and reduce the load on the program server (Tomcat,Jboss, etc.), for static resources such as pictures, js,css and other files, we can cache them in the reverse proxy server, so that when the browser requests a static resource, the proxy server can directly process the request without forwarding the request to the back-end server. The dynamic files requested by the user, such as servlet,jsp, are forwarded to the Tomcat,Jboss server for processing, which is the separation of movement and movement. This is also an important role of the reverse proxy server.
(2) forward proxy and reverse proxy
1. Forward agent:
Explanation: the legendary agent, whose working principle is like a springboard, to put it simply, I am a user, I cannot access a website, but I can access a proxy server, this proxy server, he can access the website that I cannot access, so I first connect to the proxy server and tell him that I need the content that cannot be accessed by the website, and the proxy server will get it back and return it to me. From the point of view of the website, there is only one record when the proxy server comes to pick up the content, sometimes does not know that it is the user's request, and hides the user's information, depending on whether the agent tells the site or not.
Conclusion: a forward proxy is a server located between the client and the original server (origin server). In order to get the content from the original server, the client sends a request to the agent and specifies the target (the original server), and then the agent transfers the request to the original server and returns the obtained content to the client. The client must make some special settings to use the forward proxy. It's like accessing google with * * proxy * * (the user knows to access the real server).
2. Reverse proxy:
Explanation: for example, a user visits http://www.example.com/readme, but there is no readme page on www.example.com. He secretly takes it from another server and vomits it to the user as his own content, but the user does not know it. The server corresponding to the domain name www.example.com mentioned here has set up the reverse proxy feature.
Conclusion: the reverse proxy is just the opposite, it is like the original server to the client, and the client does not need to make any special settings. The client sends a normal request to the content in the reverse proxy's namespace (name-space), which then determines where to forward the request (the original server) and returns the obtained content to the client as if it were already its own. (the user does not know to access the real server)
Nginx implements load balancing through reverse proxy.
Second, experimental examples
Experimental environment:
Host operating system IP address main software
Nginx Server CentOS 7.4x86_64 192.168.109.185 nginx-1.12.0.tar.gz
Tomcat Server 1 CentOS 7.4x86_64 192.168.109.188 apache-tomcat-9.0.16.tar.gz
Tomcat Server 2 CentOS 7.4x86_64 192.168.109.189 apache-tomcat-9.0.16.tar.gz
- -
The steps of the experiment:
-install JDK -upload the jdk package to the / root directory to install JDK [root @ localhost ~] # rpm-ivh jdk-8u201-linux-x64.rpm warning: jdk-8u201-linux-x64.rpm: header V3 RSA/SHA256 Signature Key ID ec551f03: NOKEY preparation. # # [100%] upgrading / installing... 1:jdk1.8-2000:1.8.0_201-fcs # # [100%] Unpacking JAR files... Tools.jar... Plugin.jar... Javaws.jar... Deploy.jar... Rt.jar... Jsse.jar... Charsets.jar... Localedata.jar... ● confirms the jdk installation directory ● [root@localhost ~] # cd / usr/java/jdk1.8.0_201-amd64/ [root@localhost jdk1.8.0_201-amd64] # ll Total usage 25980drwxr-xr-x 2 root root 4096 March 7 22:09 bin-rw-r--r-- 1 root root 3244 December 16 03:45 COPYRIGHTdrwxr-xr-x 3 root root 132 March 7 22:09 include-rw-r -- root root-1 root root 5207434 December 12 17:07 javafx-src.zipdrwxr-xr-x 5 root root 185 March 7 22:09 jredrwxr-xr-x 5 root root 245 March 7 22:09 lib-rw-r--r-- 1 root root 40 December 16 03:45 LICENSEdrwxr-xr-x 4 root root 47 March 7 22:09 man-rw-r--r-- 1 root root 159 December 16 03:45 README .html-rw-r--r-- 1 root root 424 December 16 03:45 release-rw-r--r-- 1 root root 21103945 December 16 03:45 src.zip-rw-r--r-- 1 root root 108109 December 12 17:07 THIRDPARTYLICENSEREADME-JAVAFX.txt-rw-r--r-- 1 root root 155002 December 16 03:45 THIRDPARTYLICENSEREADME.txt## sets the JDK environment variable # # [root@localhost ~] # vi / etc/profile # # add # export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jarexport PATH=$JAVA_HOME/bin:$ path [root @ localhost ~] # source / etc/profile # # Environment variable takes effect # # [root@localhost ~] # java-version # View java version # # java version "1.8.0mm 201" Java (TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot (TM) 64-Bit Server VM (build 25.201-b09) Mixed mode) # # Editing the java base script Test environment [root@localhost profile.d] # cd / opt [root@localhost opt] # lsrh [root@localhost opt] # vim abc.javapublic class HelloWorld {public static void main (String [] args) {System.out.println ("Hello, World!") }} [root@localhost opt] # javac abc.java # compile [root@localhost opt] # lsabc.class abc.java rh [root@localhost opt] # java abc # run abc-- installation configuration tomcat-- -- tar zxvf apache-tomcat-9.0.16.tar.gz-C / optcd / opt/lsmv apache-tomcat-9.0.16/ / usr/tomcat8cd / usr/lscd tomcat8/cd conf/cd.. / bin/## enable the tomcat service [root@localhost bin] # / startup.sh Using CATALINA_BASE: / usr/local/tomcat8Using CATALINA_HOME: / usr/local/tomcat8Using CATALINA_TMPDIR: / usr/local/tomcat8/tempUsing JRE_HOME: / usr/javaUsing CLASSPATH: / usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jarTomcat started. [root@localhost bin] # netstat-natp | grep 8080 firewall # turn off the firewall [root@localhost bin] # systemctl disable firewalld.service Removed symlink / etc/systemd/system/multi -user.target.wants/firewalld.service.Removed symlink / etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@localhost bin] # systemctl stop firewalld.service [root@localhost bin] # setenforce 0 [root@localhost bin] # Test win10 web page access http://192.168.109.187:8080# join the test page mkdir-pv / web/webapp1vim / web/webapp1/index.jsp JSP test1 page cd.. / conf/vim server .xml / / add / / the document benchmark directory of the last two lines of docBase:web application reloadable setting listens to "class" whether to change path= ", set default" class "# # start service cd.. / bin/./shutdown.sh./startup.sh## test win10 web page access http://192.168.109.187:8080 -- install another tomcat-- the same step # Test web page to change to teas2 and 1 to make a distinction # # Test win10 web page access http: / / 192.168.109.187Rose 80Murray-compile nginx---yum-y install gcc gcc-c++ make pcre-devel Zlib-devel openssl-devel cd / opt/nginx-1.12.0useradd-s / bin/false www [root@localhost nginx-1.12.0] #. / configure\-- prefix=/usr/local/nginx\-- user=www\-- group=www\-- with-file-aio\-with-http_stub_status_module\-- with-http_gzip_static_module\-- with-http_flv_module\-- with-http_ssl_modulemake & & make install [root@localhost nginx -1.12.0] # cd / usr/local/nginx/ [root@localhost nginx] # cd conf/ [root@localhost conf] # vim nginx.conf keepalive_timeout 65 # gzip on; upstream tomcat-server {server 192.168.109.188 server 8080 weight=1; # add server 192.168.109.189 weight=1;}. # access_log logs/host.access.log main; location / {root html; index index.html index.htm Proxy_pass http://tomcat-server; # add this line to configure web page jump} # start the service Close the firewall [root@localhost conf] # cd.. / [root@localhost nginx] # lsconf html logs sbin [root@localhost nginx] # cd sbin/ [root@localhost sbin] # lsnginx [root@localhost sbin] #. / nginx-tnginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful [root@localhost sbin] #. / nginx [root@localhost sbin] # netstat-natp | grep nginx tcp 00 0.0.0.0 etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink 80 0.0.0.0 LISTEN 53555/nginx: master [root@localhost sbin] # systemctl disable firewalld.service Removed symlink / etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink / etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@localhost sbin] # systemctl stop firewalld.service [root@localhost sbin] # setenforce 0 [ Root@localhost sbin] #-Test-- is it helpful for you to see the above content after visiting win10? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.