umi qiankun部署在同一个ip和端口

2022-12-13  本文已影响0人  LXEP

nginx配置

server {
    listen 80;
    listen [::]:80;
    # root /var/www/html/xxx.cn;
    # index index.html index.htm;
    server_name xxx.cn www.xxx.cn;
    
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
    
     # 主应用
    location / {
        root /var/www/html/xxx.cn;
        index index.html index.htm;
        try_files $uri $uri/ /index.html =404;
    }
    
     # app1-react 子应用app1
    location /app1-react {
        # 前端打包后静态文件所在位置,可以和上下文路径不一致,注意 root 和 alias 的用法
        alias   /var/www/html/xxx.cn/sub/app1-react/;
        index  index.html index.htm;
        # 处理 单页面应用 路由模式为 history 模式刷新页面 404 的问题
        try_files $uri $uri/ /index.html =404;
    }
    
     # app2-react 子应用app1
    location /app2-react {
        # 前端打包后静态文件所在位置,可以和上下文路径不一致,注意 root 和 alias 的用法
        alias   /var/www/html/xxx.cn/sub/app2-react/;
        index  index.html index.htm;
        # 处理 单页面应用 路由模式为 history 模式刷新页面 404 的问题
        try_files $uri $uri/ /index.html =404;
    }
    
    location ~ ^/favicon.ico$
    {
        root /var/www/xxx.cn;
    }
    
    #error_page  404              /404.html;
    error_page  404              /404.html;
    location = /404.html {
        root   html;
    }
    
    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}
上一篇 下一篇

猜你喜欢

热点阅读