nginx配置不同域名 访问vue项目的不同目录

需求如下:

有两个域名,

  • a.yao.info
  • b.yao.info

vue项目有两个路由菜单:

  • 127.0.0.1/user/login
  • 127.0.0.1/shoppingMall

目前需要访问 a.yao.info这个域名的时候,跳转到 127.0.0.1/user/login 这个路由,访问 b.yao.info这个域名的时候,跳转到 127.0.0.1/user/shoppingMall这个

求大佬们帮帮忙

 

#user  nobody;

worker_processes  1;



#pid        logs/nginx.pid;



events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    access_log  /usr/local/nginx/logs/access.log;

    sendfile        on;

    #tcp_nopush     on;

    #keepalive_timeout  0;

    keepalive_timeout  65;

    #gzip  on;



    server {

        listen       80;

        #server_name  localhost;

		server_name  a.yao.info;

        #charset koi8-r;



        #access_log  logs/host.access.log  main;



        location / {

           #root   html;

           #index  index.html index.htm;

           proxy_pass http://127.0.0.1/user/login/;

        }



        #error_page  404              /404.html;



        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

   server {

     listen       80;

     server_name  b.yao.info;



    location / {

       #root   html;

       #index  index.html index.htm;

       proxy_pass http://127.0.0.1/shoppingMall/;



    }

}



}

 

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps: 问答会员年卡【8折】购 ,限时加赠IT实体书,即可 享受50次 有问必答服务,了解详情>>>https://t.csdnimg.cn/RW5m