nodejs php 部署在同一nginx的 server 段

server {
        ###SiteName  activity
        listen       *:80;
        server_name  a.cc;
        root         "/data/www";
      
        autoindex    on;
        index        index.php index.html index.htm;
        try_files   $uri  $uri/ /index.php?$args;
        
        
        set $node_port 6789;   #nodejs 端口
        
        

        location  ~ [^/]\.php(/|$) {
                fastcgi_split_path_info  ^(.+?\.php)(/.*)$;
                if (!-f $document_root$fastcgi_script_name) {
                        return 404;
                }
                fastcgi_pass   127.0.0.1:9001;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO        $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;
        }
        
        #nodejs 项目路径包含 scheme_node_act
        location ~*/scheme_node_act/ {
            proxy_http_version 1.1;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://127.0.0.1:$node_port$request_uri; 
            proxy_redirect off;
        }
        
    }

 

posted @ 2017-09-04 10:57  shijiu520  阅读(461)  评论(0编辑  收藏  举报