ubuntu 15.0
1.安装nodejs,之前就安装了。
2.安装nginx ,我采用的直接apt-get install nginx安装
3.进入 /etc/nginx/nginx.conf,在里面http里添加如下代码:
upstream nodejs {
server 127.0.0.1:3000;
#server 127.0.0.1:3001;
keepalive 64;
}
server {
listen 80;
server_name http://oceansite.website;
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_set_header Connection "";
proxy_pass http://nodejs;
}
}
server下的结点:
listen:监听80端口
server_name:转发到哪个地址
proxy_pass:代理到哪个地址
nginx常用命令(要进入到nginx的目录):
开启:start nginx
重启:nginx -s reload