nginx配置反向代理和动静分离应用

一. Nginx配置反向代理和实现动静分离与虚拟主机流程图:
nginx配置反向代理和动静分离应用_第1张图片

二 .Nginx配置反向代理和实现动静分离与虚拟主机实现详细配置和效果图

2.1 nginx 配置反向代理

#在nginx.conf配置server同级下配置
include tomcat.conf
# vim tomcat.conf
upstream api.z.mukewang.com{
   server 172.17.41.6:8088; #这个是后台war服务部署在tomcat中
}
server {
	listen 80;
	server_name api.z.mukewang.com;
	location ~ {
		proxy_pass http://api.zmukewang.com;
	}
}

解释说明一下:
访问http://api.zmukewang.com/foodie-dev-api/doc.html -->>代理到172.17.41.6:8088/foodie-dev-api/doc.html
nginx配置反向代理和动静分离应用_第2张图片

2.2 Nginx实现动静分离与虚拟主机

#在nginx.conf配置server同级下配置
include foodie.conf
# vim foodie.conf
server{
	listen 80;
	server_name shop.z.mukewang .com;
	location / {
		root /home/website/foodie-shop;
		index index.html;
	}
}

server{
	listen 80;
	server_name center.z.mukewang .com;
	location / {
		root /home/website/foodie-center;
		index index.html;
	}
}

nginx配置反向代理和动静分离应用_第3张图片

你可能感兴趣的:(java架构笔记,nginx,反向代理,动静分离)