一、单个项目部署

     location /{
            root   /home/appuser/fuweizhong/xxx-ui/dist/;
            try_files $uri $uri/ /index.html;
            index index.html index.htm;
        }
        
        location /prod-api/ {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:8080/;
        }

访问路径:http://127.0.0.1

二、多项目部署

location ^~/energy/{
            root   /home/appuser/fuweizhong/xxx-ui/;
            try_files $uri $uri/ /index.html;
            index index.html index.htm;
        }
        
        location ^~/prod-api/ {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:8080/;
        }
        
        location ^~/park/{
            root   /home/appuser/fuweizhong/xxx-ui/;
            try_files $uri $uri/ /index.html;
            index index.html index.htm;
        }
        
        location ^~/park-api/ {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:8081/;
        }

多个项目时,使用前缀区分项目,前缀加了后,访问路径为  location+前缀:

nginx 配置多个项目--前后端分离

相关文章:

  • 2021-06-10
  • 2021-11-20
  • 2021-10-03
  • 2022-02-07
  • 2021-12-27
  • 2021-10-23
  • 2021-09-15
  • 2021-04-16
猜你喜欢
  • 2021-12-02
  • 2021-08-16
  • 2021-12-29
  • 2021-05-22
  • 2021-08-10
  • 2021-12-10
  • 2022-01-06
相关资源
相似解决方案