以下是一个基于原始Nginx和Spring Boot的项目部署示例:
- 安装Nginx:
# Ubuntu/Debian 系统
sudo apt update
sudo apt install nginx
 
# CentOS 系统
sudo yum install epel-release
sudo yum install nginx- 配置Nginx服务器块(通常位于/etc/nginx/sites-available/default):
server {
    listen 80;
    server_name your_domain_or_IP;
 
    location / {
        proxy_pass http://localhost:8080; # Spring Boot 应用的端口
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}- 启动Spring Boot应用并确保其在8080端口上运行。
- 重启Nginx服务以应用配置更改:
# Ubuntu/Debian 系统
sudo systemctl restart nginx
 
# CentOS 系统
sudo systemctl restart nginx现在,你的Spring Boot应用应该可以通过Nginx服务器转发的80端口访问了。确保防火墙设置允许80端口的流量通过。
注意:这是一个非常基础的部署示例,实际部署可能需要考虑更多因素,如HTTPS配置、负载均衡、安全性考虑(如请求的防伪造头部等)、监控和日志管理等。