部署方法:
部署web静态页面,通过nginx反向代理。因为我们公司有haproxy,因此通过了两次反向代理,域名必须在haproxy,nginx配置。如下:
部署项目:pims-admin-fed
先配置haproxy,在配置文件里添加如下内容,
acl mallPims hdr(host) -i pims.daxmall.com
use_backend Pimsbackend if mallPims
backend Pimsbackend
balance roundrobin ##负载均衡策略
server JKM-MALL-6.53 10.0.6.53:80 cookie JKM-MALL-6.53 check inter 2000 rise 3 fall 3 weight 20
server JKM-MALL-6.54 10.0.6.54:80 cookie JKM-MALL-6.54 check inter 2000 rise 3 fall 3 weight 20
在配置nginx,在配置文件里添加如下:
cd /apps/svr/nginx/conf/vhosts
vim pims-api.daxmall.com.conf
server {
listen 80;
server_name pims.daxmall.com;
#server_name mallbeta2.daxmall.com www.daxmall.com;
error_page 500 502 503 504 /50x.html;
access_log /apps/svr/nginx/logs/uat-pims-api-daxmall.access.log log_access;
location / {
root /apps/dat/web/pims-admin-fed-prod;
}
}
mkdir /apps/dat/web/pims-mobile-fed-prod #创建存放静态文件目录
到此,项目环境已经部署好。
还有别的需求,比如url重定向。需要在nginx上配置
如:activity-fed项目
server {
listen 80;
server_name activity.daxmall.com;
error_page 500 502 503 504 /50x.html;
location / {
root /apps/dat/web/activity-mobile-fed;
index index.html index.htm;
if ($query_string ~* "id=(\d+)$"){ #匹配请求的参数
set $ID $1;
rewrite /mall/topic.* http://activity.daxmall.com/#/topic/$ID?;
}
}
if ($request_uri ~* "/mall/(\d+)"){ #匹配请求的url
set $SUM $1;
rewrite /mall/2017.* http://activity.daxmall.com/#/mall/$SUM;
}
}
业务静态项目有下面这些
编号
|
项目名称
|
---|---|
1 | /apps/dat/web/supplier-admin-fed |
2 | /apps/dat/web/cshop-mobile-fed |
3 | /apps/dat/web/report-admin-fed |
4 | /apps/dat/web/oms-admin-fed-prod |
5 | /apps/dat/web/pims-mobile-fed |
6 | /apps/dat/web/activity-mobile-fed |
7 | /apps/dat/web/pms-admin-fed-prod |
8 |
/apps/dat/web/pims-admin-fed |