🔖 nginx demo3
parent
5fa1c935e8
commit
6b6e8446ff
|
@ -0,0 +1,38 @@
|
||||||
|
upstream home_server {
|
||||||
|
server www.demo03.com:9030;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream product_server {
|
||||||
|
server www.demo03.com:9031;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream user_server {
|
||||||
|
server www.demo03.com:9032;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name www.demo03.com;
|
||||||
|
|
||||||
|
charset utf-8;
|
||||||
|
proxy_connect_timeout 180;
|
||||||
|
proxy_send_timeout 180;
|
||||||
|
proxy_read_timeout 180;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
|
||||||
|
# root /home/nginx/demos;
|
||||||
|
root ../../../javaapp/src/main/webapp;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://home_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /product/{
|
||||||
|
proxy_pass http://product_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /user/ {
|
||||||
|
proxy_pass http://user_server;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
rem -----------------------------------------------------------------------------
|
||||||
|
rem Demo03 - 网站有多个 webapp 的配置(Nginx/demos/nginx-1.14.0/conf/demos/demo03.conf)
|
||||||
|
rem 1. 启动 Nginx
|
||||||
|
rem 2. 启动三个 JavaApp,访问地址分别为:
|
||||||
|
rem localhost:9030/
|
||||||
|
rem localhost:9032/product
|
||||||
|
rem localhost:9033/user
|
||||||
|
rem -----------------------------------------------------------------------------
|
||||||
|
@echo off
|
||||||
|
echo ">>>> 1. Start nginx"
|
||||||
|
cd "../nginx-1.14.0"
|
||||||
|
call nginx-start.bat
|
||||||
|
|
||||||
|
echo ">>>> 2. Start 3 java app: localhost:9030、localhost:9031/product、localhost:9032/user"
|
||||||
|
cd "../javaapp"
|
||||||
|
start /min java -Dtomcat.connector.port=9030 -Dtomcat.context.path=/ -cp "target/JavaWebApp/WEB-INF/classes;target/JavaWebApp/WEB-INF/lib/*" io.github.dunwu.app.Main
|
||||||
|
start /min java -Dtomcat.connector.port=9031 -Dtomcat.context.path=/product -cp "target/JavaWebApp/WEB-INF/classes;target/JavaWebApp/WEB-INF/lib/*" io.github.dunwu.app.Main
|
||||||
|
start /min java -Dtomcat.connector.port=9032 -Dtomcat.context.path=/user -cp "target/JavaWebApp/WEB-INF/classes;target/JavaWebApp/WEB-INF/lib/*" io.github.dunwu.app.Main
|
||||||
|
pause
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue