文章摘要:ubuntu怎么用nginx绑定域名 nginx 绑定域名
ubuntu用nginx绑定域名的示例: 1.准备configuration,将以下的配置文件内容放入/etc […]
ubuntu用nginx绑定域名的示例:
1.准备configuration,将以下的配置文件内容放入/etc/nginx/sites-available/node-app文件中,内容:
upstream node_server {
server 127.0.0.1:3000 fail_timeout=0;
server 127.0.0.1:5000 fail_timeout=0;
server 127.0.0.1:5001 fail_timeout=0;
}
server {
listen 80;
listen [::]:80 default_server;
index index.html index.htm;
server_name http://www.abc.com;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://node_server;
}
location /public/ {
root /opt/app;
}
}
2.在终端运行以下命令即可:
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/node-app /etc/nginx/sites-enabled/node-app
sudo /etc/init.d/nginx restart