一台机器部署多个tomcat服务 nginx反向代理多个服务 笔记
- 安装tomcat步骤
- 将tomcat配置成服务
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反向代理多个服务 笔记的更多相关文章
- 关于一台机器部署多个tomcat的小记
一台机器部署多个tomcat在很多时候都是有可能的,比如说多个tomcat配合nginx负载更可能好的利用CPU,或者更新程序时做主备切换等. 1.直接下载或者复制一个已有的tomcat,第一个tom ...
- 十.nginx反向代理负载均衡服务实践部署
期中集群架构-第十章-nginx反向代理负载均衡章节章节====================================================================== 0 ...
- 在centos7.6上部署前后端分离项目Nginx反向代理vue.js2.6+Tornado5.1.1,使用supervisor统一管理服务
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_102 这一次使用vue.js+tornado的组合来部署前后端分离的web项目,vue.js不用说了,前端当红炸子鸡,泛用性非常广 ...
- Linux基础-----------nginx安装和nginx web、nginx反向代理、nfs 服务
作业一:nginx服务1)二进制安装nginx包 yum install epel-release -y 先安装epel-release 再查看yum源中已经安装上了epel相关文件 中间省去了一些安 ...
- linux---nginx服务nfs服务nginx反向代理三台web
一:nginx服务 1.二进制安装nginx包 [root@bogon ~]# systemctl disable firewalld #关闭Firewalls自启动 Removed symlink ...
- Nginx高级配置,同1台机器部署多个tomcat、配置多个域名,每个域名指向某一个tomcat下的项目,共用Nginx80端口访问;
需求说明: 只有一台服务器和一个公网IP,多个项目部署在这台机器上面,且每个项目使用一个单独的域名访问,域名访问时都通过Nginx的80端口访问.(如下图所示) 配置过程: 一.tomcat的serv ...
- [Tomcat]如何在同一台机部署多个tomcat服务
背景:往往不知情的同学在同一台机器上部署多个tomcat会发现第二个tomcat启动会报错.而有些同学会想到可能是端口重复,然而,在server.xml改了端口还是发现不行.其实要想实现同一台机器部署 ...
- 一台机器启动多个tomcat简单配置
一台机器启动多个Tomcat只需要解决Tomcat端口冲突的问题. 相关配置:打开 Tomcat 目录下 conf \ server.xml 共修改三处端口,分别是: <Server port= ...
- 第四课 Grid Control实验 GC Agent安装(第一台机器部署) 及卸载
3.GC Agent安装(第一台机器部署) 安装Agent 拷贝agent,现在ocm2机器上查找agent.linux 查找文件的方法: find ./ -name agent*linux 把ag ...
随机推荐
- Shell编程(2)
1 (1) (2) (3) 一.二都是显示数组所有元素,*是作为一个长字符串输出,@是作为数组一个一个输出 三.四都是输出数组的长度 五.六都是输出数组中第一个元素的长度 (4) unset是name ...
- git同步遇到报错
git同步遇到报错 “fatal: unable to access ‘https://github.com/ruanwenwu/newp.git/‘: Peer reports incompatib ...
- Git学习笔记--命令
git init--初始化Git仓库 git add <fils>--将文件添加到暂存区,可添加多个文件,空格隔开 git commit--提交到仓库 git status--查看工作区状 ...
- 虚拟机VMware显示“内部错误”的解决方法
很有可能是VM服务没有启动,win+R services.msc 进入 “服务”,将VM相关的5个服务全部启动即可.
- Windows下Redis安装过程
1.去github下载Redis-x64-2.8.2402.zip压缩包 2.将压缩包解压到你要安装的目录下 3.将redis设置为开机自启动服务 redis-server --service-ins ...
- 安装网卡ifconfig不出现问题
安装万兆网卡,Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection 使用lspci ...
- pip install -r requirements.txt
生成文件 pip freeze > requirements.txt pip install --help Usage: pip install [options] <requiremen ...
- Image Widget 的几种加入形式
image .asset : 加载资源图片,会使打包时包体过大 image.network :网络资源图片,经常换的或者动态的图片 image file : 本地图片,比如相册 重用属性: fit ...
- Arch Linux 软件包的查询及清理
包的查询及清理 列出所有本地软件包(-Q,query查询本地:-q省略版本号) $ pacman -Qq (列出有816个包) 列出所有显式安装(-e,explicitly显式安装:-n忽略外部包AU ...
- SQLServer 账户当前被锁定
嗯,被攻击了一波,烦躁很 ‘帐户当前被锁定,所以用户 ‘sa’ 登录失败.系统管理员无法将该帐户解锁’解决方法 如果短时间内不停连接,就会被SQL SERVER误认为是这是攻击,会将此账号锁定. 要用 ...