安装nginx,使用下面网站的方式一
添加配置
cd /etc/nginx/conf.d
vi api.conf
server {
listen 80; #监听端口
root /usr/******/springboot/static/; #网站根目录,建议使用绝对路径
index index.php index.html index.htm; #默认文件location / {
root /usr/******/springboot/static/;
index index.html index.htm index.php;
}
}server {
server_name api.yumin.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
:wq!
上面就是80端口开始一个网站,api.yumin.com代理到8080服务
重启服务
systemctl restart nginx
www.yumin.com 访问页面
api.yumin.com 访问服务