• 安装tomcat步骤
          1. 下载apache-tomcat-8.0.30 ,下载下来的文件为apache-tomcat-8.0.30-windows-x64.zip
          2. 解压该压缩包到D:/目录下。
          3. 修改解压文件夹名字为:tomcat-8080
          4. 在D:/目录下创建该文件夹的两个副本,分别更名为:tomcat-8081、tomcat-8082
          5. 添加环境变量:右键单击我的电脑->选择属性->选择高级->选择环境变量:添加系统变量:
               CATALINA_HOME_8080,其值为:D:\tomcat-8080;
               CATALINA_HOME_8081,其值为:D:\tomcat-8081;
               CATALINA_HOME_8082,其值为:D:\tomcat-8082;
          6. 修改启动端口和关闭端口:
               进入D:\tomcat-8081\conf\目录,打开server.xml文件,修改下面两个地方:
               (1)<Server port="8006" shutdown="SHUTDOWN">
                         修改这个port=”8006”,使得它的关闭端口和另一个关闭端口不发生冲突。
               (2)<Connector port="8081" maxHttpHeaderSize="8192"
                              maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                              enableLookups="false" redirectPort="8443" acceptCount="100"
                              connectionTimeout="20000" disableUploadTimeout="true" />
                         修改port=”8081”,使得它的连接端口和另一个不冲突。
               (3)<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
                         修改这个port=”8010”,使得它的AJP端口和另一个不冲突。
          7. 修改startup.bat、shutdown.bat和catalina.bat文件内容:
               (1) 打开D:\tomcat-8081\bin\startup.bat文件,把其中所有CATALINA_HOME替换为CATALINA_HOME_8081。
               (2) 打开D:\tomcat-8081\bin\shutdown.bat文件,把其中所有CATALINA_HOME替换为CATALINA_HOME_8081。
               (3) 打开D:\tomcat-8081\bin\catalina.bat文件,把其中所有CATALINA_HOME替换为CATALINA_HOME_8081。
          9.按照上述方法配置tomcat-8080 ,tomcat-8082。
          10.启动Tomcat,在命令行下分别进入三个不同的Tomcat安装目录下,执行startup.bat,分别启动三个Tomcat。然后在浏览器中输入以下内容,如果显示tomcat主页,则部署成功:
       http://localhost:8080
       http://localhost:8081
       http://localhost:8082

  • 将tomcat配置成服务
          1.进入tomcat-8080/bin目录,修改 service.bat,找到以下内容,修改SERVICE_NAME为自定义的服务名
               rem Set default Service name
               set SERVICE_NAME=tomcat8080
               set DISPLAYNAME=Apache Tomcat 8.0 %SERVICE_NAME%
          2.在service.bat中搜索CATALINA_HOME,并全部替换为CATALINA_HOME_8080(与环境变量名保持一致)
          3.在tomcat-8080/bin目录下,找到tomcat8.exe和tomcat8w.exe,重命名为SERVICE_NAME配置的名字一致,这里重命名为tomcat8080.exe和tomcat8080w.exe 这个其实可以不改
          4.使用命令行进入tomcat-8080/bin,执行service.bat install
          5.使用win+r输入services.msc进入服务界面,找到DISPLAYNAME对应的服务名(即Apache Tomcat 8.0 tomcat8080),右键选择“属性”菜单,在“常规”选项卡选择“启动类型”为“自动”,或者进入tomcat-8080/bin目录 ,双击tomcat8080w.exe,在弹出的界面选中General选项卡,选择Startup type为Automatic,即开机自启动
 
nginx配置


location  = / {
# 精确匹配 / ,主机名后面不能带任何字符串
[ configuration A ]
} location / {
# 因为所有的地址都以 / 开头,所以这条规则将匹配到所有请求
# 但是正则和最长字符串会优先匹配
[ configuration B ]
} location /documents/ {
# 匹配任何以 /documents/ 开头的地址,匹配符合以后,还要继续往下搜索
# 只有后面的正则表达式没有匹配到时,这一条才会采用这一条
[ configuration C ]
} location ~ /documents/Abc {
# 匹配任何以 /documents/ 开头的地址,匹配符合以后,还要继续往下搜索
# 只有后面的正则表达式没有匹配到时,这一条才会采用这一条
[ configuration CC ]
} location ^~ /images/ {
# 匹配任何以 /images/ 开头的地址,匹配符合以后,停止往下搜索正则,采用这一条。
[ configuration D ]
} location ~* \.(gif|jpg|jpeg)$ {
# 匹配所有以 gif,jpg或jpeg 结尾的请求
# 然而,所有请求 /images/ 下的图片会被 config D 处理,因为 ^~ 到达不了这一条正则
[ configuration E ]
} location /images/ {
# 字符匹配到 /images/,继续往下,会发现 ^~ 存在
[ configuration F ]
} location /images/abc {
# 最长字符匹配到 /images/abc,继续往下,会发现 ^~ 存在
# F与G的放置顺序是没有关系的
[ configuration G ]
} location ~ /images/abc/ {
# 只有去掉 config D 才有效:先最长匹配 config G 开头的地址,继续往下搜索,匹配到这一条正则,采用
[ configuration H ]
} location ~* /js/.*/\.js

实际在用的配置

#user  nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout ; gzip on; #服务器的集群
#upstream localhost{ #服务器集群名字 #server localhost:80;#服务器配置 weight是权重的意思,权重越大,分配的概率越大。
#server 10.10.10.121:80;
#ip_hash;
#} server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location /back/ {
proxy_pass http://192.168.3.236:/back/; #后面的斜杠不能少,作用是不往后端传递/mail-api 这个路径
#roxy_redirect off;
#proxy_set_header Host mailapi.domain.com; #传递不同的host给后方节点,实现IP和域名均可以访问
#proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /common/ {
proxy_pass http://192.168.3.236:/common/;
#proxy_redirect off;
#proxy_set_header Host $host;
# proxy_set_header Host otherapi1.domain.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} location = / {
#proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://192.168.3.236:/back/login;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

proxy_pass依然能够使用error_page

  location / {
proxy_pass https://10.10.10.244:;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_intercept_errors on;
proxy_redirect default;
}

windows下重启nginx

net stop nginx
taskkill /f /t /im nginx.exe net start nginx

一台机器部署多个tomcat服务 nginx反向代理多个服务 笔记的更多相关文章

  1. 关于一台机器部署多个tomcat的小记

    一台机器部署多个tomcat在很多时候都是有可能的,比如说多个tomcat配合nginx负载更可能好的利用CPU,或者更新程序时做主备切换等. 1.直接下载或者复制一个已有的tomcat,第一个tom ...

  2. 十.nginx反向代理负载均衡服务实践部署

    期中集群架构-第十章-nginx反向代理负载均衡章节章节====================================================================== 0 ...

  3. 在centos7.6上部署前后端分离项目Nginx反向代理vue.js2.6+Tornado5.1.1,使用supervisor统一管理服务

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_102 这一次使用vue.js+tornado的组合来部署前后端分离的web项目,vue.js不用说了,前端当红炸子鸡,泛用性非常广 ...

  4. Linux基础-----------nginx安装和nginx web、nginx反向代理、nfs 服务

    作业一:nginx服务1)二进制安装nginx包 yum install epel-release -y 先安装epel-release 再查看yum源中已经安装上了epel相关文件 中间省去了一些安 ...

  5. linux---nginx服务nfs服务nginx反向代理三台web

    一:nginx服务 1.二进制安装nginx包 [root@bogon ~]# systemctl disable firewalld #关闭Firewalls自启动 Removed symlink ...

  6. Nginx高级配置,同1台机器部署多个tomcat、配置多个域名,每个域名指向某一个tomcat下的项目,共用Nginx80端口访问;

    需求说明: 只有一台服务器和一个公网IP,多个项目部署在这台机器上面,且每个项目使用一个单独的域名访问,域名访问时都通过Nginx的80端口访问.(如下图所示) 配置过程: 一.tomcat的serv ...

  7. [Tomcat]如何在同一台机部署多个tomcat服务

    背景:往往不知情的同学在同一台机器上部署多个tomcat会发现第二个tomcat启动会报错.而有些同学会想到可能是端口重复,然而,在server.xml改了端口还是发现不行.其实要想实现同一台机器部署 ...

  8. 一台机器启动多个tomcat简单配置

    一台机器启动多个Tomcat只需要解决Tomcat端口冲突的问题. 相关配置:打开 Tomcat 目录下 conf \ server.xml 共修改三处端口,分别是: <Server port= ...

  9. 第四课 Grid Control实验 GC Agent安装(第一台机器部署) 及卸载

    3.GC Agent安装(第一台机器部署) 安装Agent 拷贝agent,现在ocm2机器上查找agent.linux  查找文件的方法: find ./ -name agent*linux 把ag ...

随机推荐

  1. ssm登录与退出

    ssm整合比较好的实例 http://how2j.cn/k/ssm/ssm-tutorial/1137.html?tid=77#nowhere ssm登录后台用户检测(此实例注销有问题):http:/ ...

  2. Feign get接口传输对象引发一场追寻

    一个报错引发的追寻之路: Feign get接口传输对象,调用方接口代码: @FeignClient(name = "manage") public interface Acces ...

  3. JPA Example 基本使用使用实例

    一.相关接口方法     在继承JpaRepository接口后,自动拥有了按“实例”进行查询的诸多方法.这些方法主要在两个接口中定义,一是QueryByExampleExecutor,一个是JpaR ...

  4. Yii easyWechat 开发的时候报错:cURL error 60: SSL certificate problem: unable to get local issuer certificat

    最后配置了下php.ini文件curl.cainfo = "D:\AppServ\php5\cacert.pem" //这里填写自己对应的路径并去拷贝了下面链接的代码,自己建了个文 ...

  5. [ 随手记 5 ] C/C++ 继承

    个人理解: 继承:(意译)继续承接: A继承B,则A是派生类/子类,B为基类/父类: B有的成员变量/性质,A全部都有,而A有的B不一定有,在数学集合上可以说:B是A的子集: A继承B,可以说是A在B ...

  6. 一起学python-语法

    1.print 输出 2.定义变量:就是给变量赋一个值 name ='haha' print (name) 3.注释代码:# 注释快捷键:Ctrl +/ 4.单双引号: 如果字符串里面有单引号,外面就 ...

  7. 安装并激活pycharm

    进入 pycharm官网 https://www.jetbrains.com/pycharm/ 或直接百度pycharm进入官网 点击download now 下载专业版: 点击保存文件: 双击 py ...

  8. ITextSharp构造PDF文件

    1.1 生成Document Document是我们要生成的PDF文件所有元素的容器,因此要生成一个PDF文档,必须首先定义一个Document对象. Document有三种构造函数:    publ ...

  9. linux 下 mysql 常用命令

    linux 下 mysql 常用命令   阅读目录 ====================== 1.开启和关闭 1.1.开启 1.2.关闭 1.3.重启 2.登录 2.1.密码明文 2.2.密码密文 ...

  10. 简述iproute家族命令

    ifconfig 是用来查看.配置.启用或禁用网络接口的工具.可以用这个工具来临时配置网卡的IP地址.掩码.广播地址.网关等. 语法 ifconfig [interface] 参数 up 启动指定网络 ...