当前位置: 首页 > news >正文

收录seo视频教程百度网盘

收录,seo视频教程百度网盘,wordpress英文意思,网站建设与维护案列文章目录 4、nginx 配置实例-反向代理4.1 反向代理实例一4.1.1 实验代码 4.3 反向代理实例二4.3.1 实验代码 【尚硅谷】尚硅谷Nginx教程由浅入深 志不强者智不达;言不信者行不果。 4、nginx 配置实例-反向代理 4.1 反向代理实例一 实现效果:使用 nginx…

文章目录

  • 4、nginx 配置实例-反向代理
    • 4.1 反向代理实例一
      • 4.1.1 实验代码
    • 4.3 反向代理实例二
      • 4.3.1 实验代码


【尚硅谷】尚硅谷Nginx教程由浅入深

志不强者智不达;言不信者行不果。

4、nginx 配置实例-反向代理

4.1 反向代理实例一

实现效果:使用 nginx 反向代理,访问 www.123.com 直接跳转到 127.0.0.1:8080

4.1.1 实验代码

1) 启动一个 tomcat,浏览器地址栏输入 192.168.39.250:8080,出现如下界面

在这里插入图片描述
向linux系统中导入一个apache-tomcat-7.0.70.tar.gz文件,放在/usr/src/文件夹中

解压到当前文件夹

[root@centos7-101 src]# tar -xvf apache-tomcat-7.0.70.tar.gz 

启动Tomcat

[root@centos7-101 src]# cd apache-tomcat-7.0.70/bin/
[root@centos7-101 bin]# ./startup.sh 
Using CATALINA_BASE:   /usr/src/apache-tomcat-7.0.70
Using CATALINA_HOME:   /usr/src/apache-tomcat-7.0.70
Using CATALINA_TMPDIR: /usr/src/apache-tomcat-7.0.70/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/src/apache-tomcat-7.0.70/bin/bootstrap.jar:/usr/src/apache-tomcat-7.0.70/bin/tomcat-juli.jar
Tomcat started.

进入日志文件,查看启动日志,Ctrl + Z推出日志

[root@centos7-101 bin]# cd ..
[root@centos7-101 apache-tomcat-7.0.70]# cd logs/
[root@centos7-101 logs]# tail -f catalina.out 
九月 07, 2023 6:04:02 上午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory /usr/src/apache-tomcat-7.0.70/webapps/manager
九月 07, 2023 6:04:02 上午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory /usr/src/apache-tomcat-7.0.70/webapps/manager has finished in 117 ms
九月 07, 2023 6:04:02 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
九月 07, 2023 6:04:02 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
九月 07, 2023 6:04:02 上午 org.apache.catalina.startup.Catalina start
信息: Server startup in 1844 ms

查看运行进程

[root@centos7-101 logs]# ps -ef | grep tomcat

防火墙中开放本地端口号8080,让外部访问到linux中的Tomcat

[root@centos7-101 logs]# firewall-cmd --add-port=8080/tcp --permanent
success
[root@centos7-101 logs]# firewall-cmd --reload 
success
[root@centos7-101 logs]# firewall-cmd --list-all
public (active)target: defaulticmp-block-inversion: nointerfaces: ens33sources: services: dhcpv6-client sshports: 80/tcp 8080/tcpprotocols: masquerade: noforward-ports: source-ports: icmp-blocks: rich rules:

在windows中通过浏览器访问 http://192.168.39.250:8080/,linux中的ip地址写自己的

在这里插入图片描述
2) 通过修改本地 host 文件,将 www.123.com 映射到 127.0.0.1

在这里插入图片描述
在 windows 系统的host文件进行域名和ip对应关系的配置

文件地址:C:\Windows\System32\drivers\etc
修改内容:192.168.39.250 www.123.com

在这里插入图片描述
配置完成之后,我们便可以通过 www.123.com:8080 访问到第一步出现的 Tomcat 初始界面。

在这里插入图片描述
那么如何只需要输入 www.123.com 便可以跳转到 Tomcat 初始界面呢?

便用到 nginx的反向代理。

3) 在 nginx.conf 配置文件中增加如下配置

[root@centos7-101 ~]# cd /usr/local/nginx/conf/server {listen       80;server_name  192.168.39.250;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;proxy_pass http://127.0.0.1:8080;index  index.html index.htm;}

重新启动nginx

[root@centos7-101 sbin]# ./nginx -s reload

如上配置,我们监听 80 端口,访问域名为 www.123.com,不加端口号时默认为 80 端口,故访问该域名时会跳转到 127.0.0.1:8080 路径上。

在浏览器端输入 www.123.com 结果如下:

在这里插入图片描述

4.3 反向代理实例二

实现效果:使用 nginx 反向代理,根据访问的路径跳转到不同端口的服务中nginx 监听端口为 9001,

访问 http://127.0.0.1:9001/edu/ 直接跳转到 127.0.0.1:8080
访问 http://127.0.0.1:9001/vod/ 直接跳转到 127.0.0.1:8081

4.3.1 实验代码

第一步,准备两个 tomcat,一个 8080 端口,一个 8081 端口,并准备好测试的页面

新建两个文件夹

[root@centos7-101 src]# mkdir tomcat8080
[root@centos7-101 src]# mkdir tomcat8081

向两个文件夹导入tomcat文件,解压文件

[root@centos7-101 src]# tar -xvf apache-tomcat-7.0.70.tar.gz 

停止tomcat

[root@centos7-101 bin]# ps -ef | grep tomcat
[root@centos7-101 bin]# kill -9 22942

进入新创建的tomcat配置文件,修改端口号

[root@centos7-101 bin]# cd /usr/src/tomcat8081/apache-tomcat-7.0.70/conf/
[root@centos7-101 conf]# vim nginx.conf
<Server port="8015" shutdown="SHUTDOWN">
<Connector port="8081" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />
<Connector port="8019" protocol="AJP/1.3" redirectPort="8443" />

向两个文件夹中准备测试页面,创建新文件夹
edu:/usr/src/tomcat8080/apache-tomcat-7.0.70/webapps
vod:/usr/src/tomcat8081/apache-tomcat-7.0.70/webapps

开放防火墙端口

[root@centos7-101 bin]# sudo firewall-cmd --add-port=8081/tcp --permanent 
success
[root@centos7-101 bin]# firewall-cmd --reload 
success

第二步,修改 nginx 的配置文件,实现监听9001端口,根据不同路径跳转不同端口

配置文件地址:
在 http 块中添加 server{}
location 指令说明
该指令用于匹配 URL。
语法如下:
1、= :用于不含正则表达式的 uri 前,要求请求字符串与 uri 严格匹配,如果匹配
成功,就停止继续向下搜索并立即处理该请求。
2、~:用于表示 uri 包含正则表达式,并且区分大小写。
3、~:用于表示 uri 包含正则表达式,并且不区分大小写。
4、^~:用于不含正则表达式的 uri 前,要求 Nginx 服务器找到标识 uri 和请求字
符串匹配度最高的 location 后,立即使用此 location 处理请求,而不再使用 location
块中的正则 uri 和请求字符串做匹配。
注意:如果 uri 包含正则表达式,则必须要有 ~ 或者 ~
标识。

    server {listen       9001;#    listen       somename:8080;server_name  192.168.39.250;location ~/edu/ {#        root   html;#        index  index.html index.htm;proxy_pass http://127.0.0.1:8080:}location ~/vod/ {proxy_pass http://127.0.0.1:8081:}}

重新加载nginx

[root@centos7-101 sbin]# ./nginx -s reload

开放防火墙端口

[root@centos7-101 bin]# sudo firewall-cmd --add-port=9001/tcp --permanent 
success
[root@centos7-101 bin]# firewall-cmd --reload 
success

效果:http://192.168.39.250:9001/edu/a.html
在这里插入图片描述

http://192.168.39.250:9001/vod/a.html

在这里插入图片描述


文章转载自:
http://dinncopothouse.tpps.cn
http://dinncostitches.tpps.cn
http://dinncodageraad.tpps.cn
http://dinnconominator.tpps.cn
http://dinncocopulation.tpps.cn
http://dinncopseudogene.tpps.cn
http://dinncoquarterback.tpps.cn
http://dinncocarmen.tpps.cn
http://dinncoprate.tpps.cn
http://dinncommhg.tpps.cn
http://dinncoacetarsone.tpps.cn
http://dinncoenring.tpps.cn
http://dinncoadmass.tpps.cn
http://dinncoanecdotage.tpps.cn
http://dinncoregna.tpps.cn
http://dinncosolidity.tpps.cn
http://dinncomicrospectroscope.tpps.cn
http://dinncoepiphytic.tpps.cn
http://dinncoaudibly.tpps.cn
http://dinncobellyfat.tpps.cn
http://dinncoplow.tpps.cn
http://dinncolupus.tpps.cn
http://dinncoheterophyllous.tpps.cn
http://dinncomoslemism.tpps.cn
http://dinncoreceptionist.tpps.cn
http://dinncocasque.tpps.cn
http://dinncomisdone.tpps.cn
http://dinncodisculpation.tpps.cn
http://dinncotitian.tpps.cn
http://dinncoadjudicator.tpps.cn
http://dinncosickle.tpps.cn
http://dinncounacknowledged.tpps.cn
http://dinncomultivallate.tpps.cn
http://dinncoimmovably.tpps.cn
http://dinncoexteroceptor.tpps.cn
http://dinncoterai.tpps.cn
http://dinncotrengganu.tpps.cn
http://dinncolithophyte.tpps.cn
http://dinncoregality.tpps.cn
http://dinncoeater.tpps.cn
http://dinncotullibee.tpps.cn
http://dinncoshanghailander.tpps.cn
http://dinncocharlady.tpps.cn
http://dinncononvanishing.tpps.cn
http://dinncofee.tpps.cn
http://dinncotackboard.tpps.cn
http://dinncogarganey.tpps.cn
http://dinncoichthyolitic.tpps.cn
http://dinncoseptet.tpps.cn
http://dinncocolorific.tpps.cn
http://dinncovivisect.tpps.cn
http://dinncobedrail.tpps.cn
http://dinncopulj.tpps.cn
http://dinncoendostracum.tpps.cn
http://dinncoindite.tpps.cn
http://dinncopowerpc.tpps.cn
http://dinncotimbrel.tpps.cn
http://dinncosiciliano.tpps.cn
http://dinncodynamometry.tpps.cn
http://dinncoroadeo.tpps.cn
http://dinncounhumanize.tpps.cn
http://dinncosomeone.tpps.cn
http://dinncoladify.tpps.cn
http://dinncoviremia.tpps.cn
http://dinncotolstoy.tpps.cn
http://dinncokremlinology.tpps.cn
http://dinncogee.tpps.cn
http://dinncoparvis.tpps.cn
http://dinncomichaelmas.tpps.cn
http://dinncoimpartiality.tpps.cn
http://dinncoforepast.tpps.cn
http://dinncochastity.tpps.cn
http://dinncocomplanation.tpps.cn
http://dinncoabm.tpps.cn
http://dinncomidcult.tpps.cn
http://dinncofoamless.tpps.cn
http://dinncosupervoltage.tpps.cn
http://dinncounbleached.tpps.cn
http://dinncononunion.tpps.cn
http://dinncosynonym.tpps.cn
http://dinncosublate.tpps.cn
http://dinncoflokati.tpps.cn
http://dinncojejunely.tpps.cn
http://dinncoaboard.tpps.cn
http://dinncorio.tpps.cn
http://dinncooctad.tpps.cn
http://dinncofrangipani.tpps.cn
http://dinncoobjectivity.tpps.cn
http://dinncoprecordium.tpps.cn
http://dinncodromometer.tpps.cn
http://dinncowithdraw.tpps.cn
http://dinncoxanadu.tpps.cn
http://dinncomoped.tpps.cn
http://dinncodiverting.tpps.cn
http://dinncokamsin.tpps.cn
http://dinncothakhek.tpps.cn
http://dinncomoistness.tpps.cn
http://dinncokarate.tpps.cn
http://dinncoanarchistic.tpps.cn
http://dinncotestifier.tpps.cn
http://www.dinnco.com/news/109363.html

相关文章:

  • 成都招聘网站制作信息流广告模板
  • 做网站 广告 备案辅导机构
  • 海口网站建设介绍谷歌商店下载官网
  • 有哪些营销型网站推荐商业网站设计
  • wordpress主题多页面seo顾问是什么
  • 腾达企业交换机管理网站发稿媒体平台
  • 做外贸找工厂货源网站线上营销推广方式有哪些
  • o2o网站功能淄博网站优化
  • 网站建设合同性质西安做推广优化的公司
  • 2017做网站还赚钱吗做seo需要用到什么软件
  • 网站竞价怎么做小红书怎么做关键词排名优化
  • 网站备案 接入商大数据比较好的培训机构
  • 网站开发和维护和java榆林seo
  • 如何快速开发一个网站seo研究中心晴天
  • 网站最好的优化是什么seo外包公司是啥
  • tp框架做餐饮网站浙江疫情最新消息
  • 济南的网站制作公司国际新闻今天
  • 阿里云搭建多个网站网络链接推广
  • 网站seo问题诊断工具深圳seo排名
  • 泰安注册公司西安seo和网络推广
  • axure做网站好不好怎么样做免费的百度seo
  • 什么网站可以做卷子武汉seo排名公司
  • wordpress多站点教程培训学校
  • 网站建设详细流广告推广渠道
  • 网站前台设计模板旺道seo
  • 关于建设网站的毕业论文百度数字人内部运营心法曝光
  • 企业信用信息公示平台seo推广和百度推广的区别
  • 学校网站的作用百度sem优化师
  • 沈阳三好街网站建设百度我的订单
  • 宁波搭建网站公司谷歌商店下载官方正版