#添加完成后用"sudo service nginx restart"来重启nginxupstream myapp { server 127.0.0.1:3000;}server { listen 80; server_name myapp.com;#这里写上你自己需要的域名或ip access_log /var/log/nginx/myapp.log;# pass the request to the node.js server with the correct headers and much more can be added, see nginx config options location / { 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_pass http://myapp/; proxy_redirect off;}}
一切配置妥当后,就可以用下面的命令开启、查看、停止你的应用了:
123
sudo start myapp
sudo status myapp
sudo stop myapp