nginx用php和两个node.js路由

我有两条路线,我想通过两个节点进程(websocket路由,angular度的应用程序),而第三条路线需要传递给一个PHP应用程序,充当angular应用程序的restAPI。 我不是非常精通nginx

这是我的尝试:

user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; include /etc/nginx/conf.d/*.conf; fastcgi_hide_header Server; fastcgi_hide_header X-Powered-By; #upstream servers upstream app_servers { ip_hash; server dev.example.com:9001 weight=5; } upstream socket_servers { ip_hash; server dev.example.com:9002 weight=5; } #upstream api_servers { #ip_hash; # server dev.example.com:9000; #} server { listen 80; server_name dev.example.com; root /usr/share/nginx/html/dev/; server_tokens off; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; # cache statics location ~* .(png|gif|jpg|jpeg|ico|css|js)$ { expires max; access_log off; } # php config location ~ \.(hh|php)$ { try_files $uri = 404; location ~ \..*/.*\.php$ {return 404;} fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_keep_conn on; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #rest api location /api { include /etc/nginx/mime.types; index index.php; try_files $uri /api/index.php?$request_uri; } #websocket server location /sock { proxy_pass http://socket_servers; } #angular app location / { proxy_pass http://app_servers; } } } 

所有请求似乎最终在angular度应用程序,即使请求/sock/api 。 有任何想法吗?