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

代码导航 论文问答 1

需求如下:

有两个域名,

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这个

求大佬们帮帮忙

回复

共2条回复 我来回复
  • 源码客栈
    这个人很懒,什么都没有留下~
    评论
    #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/;
    
    
    
        }
    
    }
    
    
    
    }
    
    0条评论
  • 毕设小屋
    这个人很懒,什么都没有留下~
    评论
    #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/;
    
    
    
        }
    
    }
    
    
    
    }
    
    0条评论

发表回复

登录后才能评论