weixin_43202599
汉之广矣
2018-11-20 02:57
采纳率: 22.2%
浏览 4.8k

nginx一个域名配置多个项目怎么配?

比如我有001和002项目,项目都在/usr/local/runsoft/路径里面
有ABC.com域名

            在nginx里该怎么配
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • qq_37486884
    疯狂的熊猫Npe 2018-11-22 07:37
    已采纳

    你意思是访问两个项目都是指向到同一个IP下去吧,如果是这样的话直接

    upstream tomcat-server{
    server xxx.xxx.xx:xxxx 项目1;
    server xxx.xxx.xx:xxxx 项目2;
    }

    server {
    listen 80;
    server_name www.abc.com;
    #charset koi8-r;
    #access_log logs/host.access.log main;
    #return 301 https://$server_name$request_uri;
    location / {
    proxy_pass http://tomcat-server;
    index index.html index.htm;
    }

    }

    点赞 评论
  • mzbqhbc12
    mzbqhbc12 2018-11-29 03:31

    upstream tomcat-serve2r{

    server xxx.xxx.xx:xxxx 项目2;
    }
    upstream tomcat-server1{
    server xxx.xxx.xx:xxxx 项目1;

    }

    server {
    listen 80;
    server_name v1.abc.com;
    #charset koi8-r;
    #access_log logs/host.access.log main;
    #return 301 https://$server_name$request_uri;
    location / {
    proxy_pass http://tomcat-server1;
    index index.html index.htm;
    }

    }
    server {
    listen 80;
    server_name v2.abc.com;
    #charset koi8-r;
    #access_log logs/host.access.log main;
    #return 301 https://$server_name$request_uri;
    location / {
    proxy_pass http://tomcat-server2;
    index index.html index.htm;
    }

    }

    点赞 评论

相关推荐