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

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;
    }
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容