参考
- 正向代理与反向代理的区别 - 简书
- (一)nginx反向代理html,实现前后端分离部署
- Nginx 实现端口转发
- 在Nginx上配置多个站点
- 端口转发携带ip忘记文章地址了
nginx常用命令
sudo apt install nginx
nginx -v
sudo systemctl start nginx
sudo systemctl restart nginx
sudo nginx -s reload
配置文件参考
- 在配置文件
/etc/nginx/sites-enabled/default
末尾追加
#springboot api的配置
server{
listen 80;
server_name api.blog.xxxxxx.com;
location / {
# 你的springboot 域名+端口号
proxy_pass http://localhost:8889/;
proxy_set_header Host $http_host;
# proxy_connect_timeout 15;
# proxy_send_timeout 15;
# proxy_read_timeout 15;
# 转发携带ip
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# 网页静态文件的配置
server{
listen 80;
server_name blog.xxxxxx.com;
location / {
root /home/springboot/blog/blog.xxxxxx.com;
index index.html;
}
}