nginx 80端口转发到8086端口
查看端口占用,确保80端口不被占用
sudo lsof -i :80
sudo netstat -lnt | grep 80
在/etc/nginx/conf.d目录下增加配置文件
server {
listen 80;
server_name 127.0.0.1;
location / {
proxy_pass http://127.0.0.1:8086/;
}
}
访问80端口时始终显示“Welcome to nginx!”
这是因为nginx使用了/etc/nginx/sites-enabled/defaule这个默认配置,直接删除这个文件,然后查看实际配置
sudo rm -rf /etc/nginx/sites-enabled/defaule
sudo nginx -T
重启nginx,80端口恢复正常
sudo nginx -s reload
关注博主公众号,优质文章不断更新