Sunday, September 1, 2013

nginx node.js work together

root底下的html由nginx負責,其他動態的部分由proxy pass到node server。
 location ~* /remote {

                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 Connection "";
                proxy_pass http://backend;
                proxy_redirect off;
                proxy_buffering off;

                proxy_http_version 1.1;
                break;
}
location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
                index  index.html index.htm;
}
參考: Nginx.conf and Node.js setup scenario

No comments: