nginx

nginx 反向代理
第一步先打开文件夹在这里插入图片描述
第二步设置IP和名字 这的IP要和没有安装Tomcat保持一致
在这里插入图片描述

在安装了Tomcat里

[root@nginx ~]# rpm -ivh jdk-8u77-linux-x64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:jdk1.8.0_77-2000:1.8.0_77-fcs    ################################# [100%]
Unpacking JAR files...
        tools.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
        rt.jar...
        jsse.jar...
        charsets.jar...
        localedata.jar...
        jfxrt.jar...
[root@nginx ~]# java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
[root@nginx ~]# tar xf apache-tomcat-8.5.43.tar.gz 
[root@nginx ~]# mv apache-tomcat-8.5.43 /usr/local/
[root@nginx ~]# cd /usr/local/apache-tomcat-8.5.43/

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



在没安装Tomcat

[root@nginx conf.d]# mv zx_proxy.conf zx_proxy.conf.bak
[root@nginx conf.d]# vi proxy.conf
[root@nginx conf.d]# cat proxy.conf
server {
listen 80;
server_name www.aa1122.com;
index index.html;
location / {
proxy_pass http://192.168.137.2:8080; 这要写有tomcat的ip
include proxy_params;
}
}
[root@nginx conf.d]# vi /etc/nginx/proxy_params
[root@nginx conf.d]# cat /etc/nginx/proxy_params
proxy_redirect default;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 32k;
proxy_buffering on;
proxy_buffers 4 128k;
proxy_busy_buffers_size 256k;
proxy_max_temp_file_size 256k;

[root@nginx conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@nginx conf.d]# nginx -s reload

反向代理完成后会出现
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210512163222785.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzU3NzIxMzMy,size_16,color_FFFFFF,t_70)
在新建的虚拟机中要新建一个 nginx 
原先的虚拟机在重启后要重新开启Mysql  和nginx  记得关闭防火墙  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值