Example of ubuntu using nginx to bind a domain name:
1. Prepare the configuration and put the following configuration file contents into the /etc/nginx/sites-available/node-app file, content:
<p><br></p><p>upstream node_server {</p><p>server 127.0.0.1:3000 fail_timeout=0;</p><p>server 127.0.0.1:5000 fail_timeout=0;</p><p>server 127.0.0.1:5001 fail_timeout=0;</p><p>}</p><p><br></p><p>server {</p><p>listen 80;</p><p>listen [::]:80 default_server;</p><p><br></p><p>index index.html index.htm;</p><p><br></p><p>server_name www.abc.com;</p><p><br></p><p>location / {</p><p>proxy_set_header Host $host;</p><p>proxy_set_header X-Real-IP $remote_addr;</p><p>proxy_redirect off;</p><p>proxy_buffering off;</p><p>proxy_pass http://node_server;</p><p>}</p><p><br></p><p>location /public/ {</p><p>root /opt/app;</p><p>}</p><p>}</p><p><br></p>
2. Run the following command in the terminal:
<p>sudo rm /etc/nginx/sites-enabled/default</p><p>sudo ln -s /etc/nginx/sites-available/node-app /etc/nginx/sites-enabled/node-app</p><p>sudo /etc/init.d/nginx restart</p><p><br></p>
The above is the detailed content of How to bind domain name with nginx in ubuntu. For more information, please follow other related articles on the PHP Chinese website!