Назад | Перейти на главную страницу

nginx с php и двумя маршрутами node.js

У меня есть два маршрута, по которым я хочу передать два процесса узла (маршрут websocket, приложение angular), в то время как третий маршрут необходимо передать приложению php, которое действует как api отдыха для приложения angular. я не очень хорошо разбираюсь в 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. Любые идеи?