天天看點

nginx 配置代理和虛拟目錄示例

server

{

        listen 80;

        server_name songaimin.xxx.cn 

        #index index.php index.html index.htm;

        access_log  /home/songaimin/job/logs/songaimin.access.log;

        root /home/songaimin/job/php-prj/isou;

        #root /var/www/isou;

#配置代理

        location /CarOwner/{

                proxy_pass http://songaimin.xxxx.cn/owner/;

                #proxy_redirect  off;

                #proxy_set_header Host $http_host;

                #proxy_set_header X-Real-IP $remote_addr;

                #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_set_header Cookie $http_cookie;

        }

        # 配置虛拟目錄

        location /owner/

        {

                alias /home/songaimin/job/php-prj/paimai/;

                index clcwsite.php index.html;

                rewrite ^/owner/clcwsite.php(.*)$ /owner/clcwsite.php?s=$1 last;

                rewrite ^/owner/(.*)$ /owner/clcwsite.php?s=$1 last;

                break;

        }

#配置php解析

        location ~ ^/owner/(.+\.)(php|php5)?$

        {

                alias /home/songaimin/job/php-prj/paimai/;

                fastcgi_param SCRIPT_FILENAME $document_root$1$2;

                fastcgi_pass  127.0.0.1:9000;

                include fastcgi_params;

                #include fastcgi.conf;

        }

}

繼續閱讀