bash
sudo apt-get update
sudo apt-get install nginx
sudo nginx -v
sudo systemctl status nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
#浏览器输入:http://192.168.31.181/
#查看文件结构
cd /etc/nginx
sudo cp nginx.conf nginx.conf-org
#添加一个站点代理
nano /etc/nginx/conf.d/api.demo.com.conf
====================
server {
server_name api.demo.com;
location / {
proxy_pass http://192.168.31.142:5001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
}
===========================
#host添加一段
192.168.31.181 api.demo.com
浏览器访问: