Lastly start the node server: cd /var/www/yourdomain/ & node app.js Restart nginx: sudo /etc/init.d/nginx restart Ln -s /etc/nginx/sites-available/ Ĭreate your node server app at /var/www/yourdomain/app.js and run it at localhost:3000 var http = require('http') Once you have this setup you must enable the site defined in the config file above: cd /etc/nginx/sites-enabled/ If you want nginx (>= 1.3.13) to handle websocket requests as well, add the following lines in the location / section: proxy_http_version 1.1 Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for # and much more can be added, see nginx config options # pass the request to the node.js server with the correct headers In it you should have something like: # the IP(s) on which your node server is running. This is what I have done in my Ubuntu box:Ĭreate the file at /etc/nginx/sites-available/: vim /etc/nginx/sites-available/ Therefore you need to setup an nginx config file for node. Nginx works as a front end server, which in this case proxies the requests to a node.js server. Nginx: could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied)Ģ 13:39:44 1074#0: open() "/usr/local/var/log/nginx/access.log" failed (13: Permission denied) When i try to run Nginx i get the following error. To check if nginx is running ➜ ~ ps waux | grep nginx Nginx: bind() to 0.0.0.0:8080 failed (48: Address already in use)Ĭlient_body_temp fastcgi_temp proxy_temp scgi_temp uwsgi_temp Nginx: open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory) I install nginx via home brew and when i try to start or stop it i get the following error ➜ ~ sudo nginx -s stop
0 Comments
Leave a Reply. |