河南高级会员
专心做事,诚信做人
posts - 14,  comments - 1,  trackbacks - 0

A服务器(做反向代理):abc.conf
   #
   # The default server
   #
   server {
  
               listen       80;
               server_name  www.abc.com;
  
              location /{
                      proxy_pass              http://xxx.xxx.xxx.xxx/abc/;  ; #B服务器ip/站点目录
                      proxy_redirect          off;
                       proxy_set_header       Host            $host;
                      proxy_set_header        X-Real-IP       $remote_addr;
                     proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
             }
 
      # deny access to .htaccess files, if Apache's document root
     # concurs with nginx's one
     #
     #location ~ /\.ht {
     #    deny  all;
     #}
 }

 

B服务器(放数据):/data/html/abc/abc站点数据   www.conf

设置服务器更目录为/html/


server {
    listen       80;
    root   /data/html;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
        root   /data/html;
        index  index.html index.php;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /data/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /data/html;
    }

        if (!-e $request_filename) {
                rewrite ^.abc.*$ /abc/index.php last;

       #rewrite ^.def.*$ /def/index.php last;
                break;

        }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index   index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }




    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

多站点反向原理一样。

 

posted on 2015-03-26 15:01  河南高级会员  阅读(...)  评论(...编辑  收藏