nginx com php e duas rotas node.js

2

Eu tenho duas rotas que eu quero passar dois processos de nó (rota websocket, aplicativo angular), enquanto uma terceira rota precisa passar para um aplicativo php que atua como uma API de descanso para o aplicativo angular. Eu não sou muito proficiente com nginx

aqui está o que eu tentei:

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;
        }

    }

}

todas as solicitações parecem acabar no aplicativo angular, mesmo quando solicitam /sock e /api . alguma idéia?

    
por r3wt 27.12.2014 / 00:19

0 respostas