网站建设对应的岗位,phpstudy建wordpress,网站建设的一些知识,建站程序的选择目录 一.简介1.反向代理 二.案例1.案例12.案例2 一.简介
1.反向代理
1.1反向代理#xff1a; 是指代理服务器来接收Internet上的客户端请求#xff0c;然后将请求转发给内部网络上的服务器#xff0c;并将从服务器上得到的结果返回给客户端。此时代理服务器对外就表现为一… 目录 一.简介1.反向代理 二.案例1.案例12.案例2 一.简介
1.反向代理
1.1反向代理 是指代理服务器来接收Internet上的客户端请求然后将请求转发给内部网络上的服务器并将从服务器上得到的结果返回给客户端。此时代理服务器对外就表现为一个反向代理服务器。 反向代理客户端不知道服务器的信息隐藏了服务器的信息
1.2正向代理是一个位于客户端和原始服务器之间的服务器为了从原始服务器获得内容。客户端向代理发送一个请求并指定目标原始服务器然后代理向原始服务器转发并获得的内容返回给客户端 正向代理服务器不知道客户端的信息隐藏了客户端的信息
二.案例
1.案例1
1.1实现思路 1.2实现步骤 1.2.1Nginx配置
#配置文件中修改
vim /usr/local/nginx/conf/nginx.conf
server {listen 80;server_name 10.10.100.222;#charset koi8-r;#access_log logs/host.access.log main;location / {proxy_pass http://127.0.0.1:8080;root html;index index.html index.htm;}#检测语法是否正确
[rootlocalhost sbin]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful#重新加载nginx
[rootlocalhost ~]# /usr/local/nginx/sbin/nginx -s reload1.2.2搭建tomcat tomcat包和jdk包 链接https://pan.baidu.com/s/12n0LNdXiXIJh-GNQwp2WNw 提取码7ptr –来自百度网盘超级会员V1的分享 链接https://pan.baidu.com/s/1yuBmzZ76QShBfBnrrgDLfA 提取码hk96 –来自百度网盘超级会员V1的分享 安装jdk环境
#先创建java文件目录如果已存在就不用创建
mkdir -p /usr/local/java#解压到java文件目录
tar -vzxf jdk-8u161-linux-x64.tar.gz -C /usr/local/java/#配置环境变量
vi /etc/profile
export JAVA_HOME/usr/local/java/jdk1.8.0_11
export CLASSPATH$CLASSPATH:$JAVA_HOME/lib/
export PATH$PATH:$JAVA_HOME/bin#生效环境变量
source /etc/profile下载Tomcat、解压Tomcat、安装Tomcat、启动Tomcat
#解压tomcat
tar -zxvf apache-tomcat-9.0.78.tar.gz#安装tomcat
mv apache-tomcat-9.0.78 /usr/local/tomcat#启动tomcat
/usr/local/tomcat/bin/startup.sh1.3测试 可以看到tomcat的界面实际上是访问ngnix跳转到tomcat的8080端口
2.案例2
2.1实现思路 2.2实现步骤
#修改配置文件
server {listen 80;server_name 10.10.100.222;#charset koi8-r;#access_log logs/host.access.log main;location ~/aaa/ {proxy_pass http://127.0.0.1:8080;}location ~/bbb/ {proxy_pass http://127.0.0.1:8081;}
}#重新加载nginx
/usr/local/nginx/sbin/nginx -s reload2.2.1拷贝两个Tomcat将其中一个的端口信息修改为8081
#拷贝两个tomcattar -zxvf apache-tomcat-9.0.78.tar.gzmv apache-tomcat-9.0.78 /usr/local/tomcat1tar -zxvf apache-tomcat-9.0.78.tar.gzmv apache-tomcat-9.0.78 /usr/local/tomcat2#删除tomcat2下面的配置
rm -f /usr/local/tomcat2/conf/server.xml#添加新配置文件
vi /usr/local/tomcat2/conf/server.xml
!-- Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the License); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an AS IS BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.--
!-- Note: A Server is not itself a Container, so you may notdefine subcomponents such as Valves at this level.Documentation at /docs/config/server.html--
Server port8006 shutdownSHUTDOWN
Listener classNameorg.apache.catalina.startup.VersionLoggerListener/
!-- Security listener. Documentation at /docs/config/listeners.htmlListener classNameorg.apache.catalina.security.SecurityListener /--
!-- APR library loader. Documentation at /docs/apr.html --
Listener classNameorg.apache.catalina.core.AprLifecycleListener SSLEngineon/
!-- Prevent memory leaks due to use of particular java/javax APIs --
Listener classNameorg.apache.catalina.core.JreMemoryLeakPreventionListener/
Listener classNameorg.apache.catalina.mbeans.GlobalResourcesLifecycleListener/
Listener classNameorg.apache.catalina.core.ThreadLocalLeakPreventionListener/
!-- Global JNDI resourcesDocumentation at /docs/jndi-resources-howto.html--
GlobalNamingResources
!-- Editable user database that can also be used byUserDatabaseRealm to authenticate users--
Resource nameUserDatabase authContainer typeorg.apache.catalina.UserDatabase descriptionUser database that can be updated and saved factoryorg.apache.catalina.users.MemoryUserDatabaseFactory pathnameconf/tomcat-users.xml/
/GlobalNamingResources
!-- A Service is a collection of one or more Connectors that sharea single Container Note: A Service is not itself a Container,so you may not define subcomponents such as Valves at this level.Documentation at /docs/config/service.html--
Service nameCatalina
!-- The connectors can use a shared executor, you can define one or more named thread pools --
!-- Executor nametomcatThreadPool namePrefixcatalina-exec-maxThreads150 minSpareThreads4/--
!-- A Connector represents an endpoint by which requests are receivedand responses are returned. Documentation at :Java HTTP Connector: /docs/config/http.htmlJava AJP Connector: /docs/config/ajp.htmlAPR (HTTP/AJP) Connector: /docs/apr.htmlDefine a non-SSL/TLS HTTP/1.1 Connector on port 8080--
Connector port8081 protocolHTTP/1.1 connectionTimeout20000 redirectPort8443 maxParameterCount1000/
!-- A Connector using the shared thread pool --
!-- Connector executortomcatThreadPoolport8081 protocolHTTP/1.1connectionTimeout20000redirectPort8443maxParameterCount1000/--
!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443This connector uses the NIO implementation. The defaultSSLImplementation will depend on the presence of the APR/nativelibrary and the useOpenSSL attribute of the AprLifecycleListener.Either JSSE or OpenSSL style configuration may be used regardless ofthe SSLImplementation selected. JSSE style configuration is used below.--
!-- Connector port8443 protocolorg.apache.coyote.http11.Http11NioProtocolmaxThreads150 SSLEnabledtruemaxParameterCount1000SSLHostConfigCertificate certificateKeystoreFileconf/localhost-rsa.jkstypeRSA //SSLHostConfig/Connector--
!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2This connector uses the APR/native implementation which always usesOpenSSL for TLS.Either JSSE or OpenSSL style configuration may be used. OpenSSL styleconfiguration is used below.--
!-- Connector port8443 protocolorg.apache.coyote.http11.Http11AprProtocolmaxThreads150 SSLEnabledtruemaxParameterCount1000UpgradeProtocol classNameorg.apache.coyote.http2.Http2Protocol /SSLHostConfigCertificate certificateKeyFileconf/localhost-rsa-key.pemcertificateFileconf/localhost-rsa-cert.pemcertificateChainFileconf/localhost-rsa-chain.pemtypeRSA //SSLHostConfig/Connector--
!-- Define an AJP 1.3 Connector on port 8009 --
!-- Connector protocolAJP/1.3address::1port8010redirectPort8443maxParameterCount1000/--
!-- An Engine represents the entry point (within Catalina) that processesevery request. The Engine implementation for Tomcat stand aloneanalyzes the HTTP headers included with the request, and passes themon to the appropriate Host (virtual host).Documentation at /docs/config/engine.html --
!-- You should set jvmRoute to support load-balancing via AJP ie :Engine nameCatalina defaultHostlocalhost jvmRoutejvm1--
Engine nameCatalina defaultHostlocalhost
!-- For clustering, please take a look at documentation at:/docs/cluster-howto.html (simple how to)/docs/config/cluster.html (reference documentation) --
!-- Cluster classNameorg.apache.catalina.ha.tcp.SimpleTcpCluster/--
!-- Use the LockOutRealm to prevent attempts to guess user passwordsvia a brute-force attack --
Realm classNameorg.apache.catalina.realm.LockOutRealm
!-- This Realm uses the UserDatabase configured in the global JNDIresources under the key UserDatabase. Any editsthat are performed against this UserDatabase are immediatelyavailable for use by the Realm. --
Realm classNameorg.apache.catalina.realm.UserDatabaseRealm resourceNameUserDatabase/
/Realm
Host namelocalhost appBasewebapps unpackWARstrue autoDeploytrue
!-- SingleSignOn valve, share authentication between web applicationsDocumentation at: /docs/config/valve.html --
!-- Valve classNameorg.apache.catalina.authenticator.SingleSignOn /--
!-- Access log processes all example.Documentation at: /docs/config/valve.htmlNote: The pattern used is equivalent to using patterncommon --
Valve classNameorg.apache.catalina.valves.AccessLogValve directorylogs prefixlocalhost_access_log suffix.txt pattern%h %l %u %t %r %s %b/
/Host
/Engine
/Service
/Server#创建文件夹和文件mkdir -p /usr/local/tomcat1/webapps/aaamkdir -p /usr/local/tomcat2/webapps/bbbecho h1This is 8080 Port/h1 /usr/local/tomcat1/webapps/aaa/a.htmlecho h1This is 8081 Port/h1 /usr/local/tomcat2/webapps/bbb/b.html#启动tomcat
/usr/local/tomcat1/bin/startup.sh
/usr/local/tomcat2/bin/startup.sh2.3测试