1.后端有8088、8089两个端口不同的模块
2.在nginx里配置地址。监听端口:9001,转发端口:8088、8099
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
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 65;
#gzip on;
server {
listen 9001;
server_name localhost; #域名
#server_name service-cmn; #域名
#index index.html; #指定的server的root的访问页面
#root #指定的server的root目录
#charset koi8-r;
#access_log logs/host.access.log main;
#我工程的context-path=mytest
location ~/cmn/ {
proxy_pass http://localhost:8089;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
# root html;
# index index.html index.htm;
}
#我工程的context-path=mytest
location ~/hosp/ {
proxy_pass http://localhost:8088;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
# root html;
# index index.html index.htm;
}
}
}
启动nginx
3.前端在dev.env.js里配置地址。应配置nginx的配置文件里的监听端口的地址,即9001