nginx 一個域名配置多個項目的根目錄

server
{
    listen 80;
    server_name xx.cn;
    index index.php index.html index.htm default.php default.htm default.html;
    location /qyzg/ {

        root /home/wwwroot/zhibo/testgzh/;

        try_files $uri $uri/ /qyzg_index.html last;


        break;
    }

    root   /home/wwwroot/zhibo/gzh/web;
    location / {
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=/$1  last;
            break;
        }
    }

    location ~ .*\.*chunk.*(js|css)?$
    {
        expires      12h;
        error_log off;
        access_log /dev/null; 
        
        if (!-e $request_filename) {
          root /home/wwwroot/zgkc/;
          break;
        }
    }

    location ~ .*\.*app.*(js|css)?$
    {
        expires      12h;
        error_log off;
        access_log /dev/null; 
        
        if (!-e $request_filename) {
          root /home/wwwroot/zgkc/;
          break;
        }
    }

    location ~ .*\.*chunk.*(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log off;
        access_log /dev/null;
        if (!-e $request_filename) {
          root /home/wwwroot/zgkc/;
          break;
        }
    }
    #通過訪問二級目錄order來訪問訂單服務服務器
    location /zgzj/ {
       proxy_pass http://xx.cn/;
     }
    access_log  /www/wwwlogs/xx.cn.log;
    error_log  /www/wwwlogs/xx.cn.error.log;
}

主要是這行代碼 反向代理

    location /zgzj/ {
       proxy_pass http://bb4.xx.cn/;
     }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章