一、ubuntu上安装nginx
sudo apt update
sudo apt install nginx
sudo systemctl status nginx
sudo ufw allow 'Nginx Full'
sudo ufw status
sudo ufw allow 2283/tcp
sudo ufw reload
二、配置文件地址
sudo vi /etc/nginx/nginx.conf
添加自定义的配置
include /etc/nginx/conf.d/*.conf;
include /home/kequan/project/yinda_django/nginx/project.conf;
include /etc/nginx/sites-enabled/*;
直接修改project.conf即可
# upstream photohome {
# server 127.0.0.1:2283;
# }
# upstream yinda {
# server 127.0.0.1:8080;
# }
# 注意:这里的端口不能和upstream中的端口相同,否则会有冲突
server {
listen 8000; # 修改为其他端口,例如80
location / {
# proxy_pass http://yinda; # 添加 http:// 前缀
proxy_pass http://127.0.0.1:8080;
}
}
server {
listen 2282;
location / {
# proxy_pass http://photohome; # 添加 http:// 前缀
proxy_pass http://127.0.0.1:2283;
}
}
三、重启nginx
systemctl restart nginx.service
四、查看nginx日志
code /var/log/nginx/error.log
code /var/log/nginx/access.log