How to Deploy a Spring Boot .jar on a VPS (with SSL)
A Spring Boot app ships its own web server, so hosting it is mostly about keeping the process running, putting HTTPS in front and handling configuration. Here is the full setup.
Short answer: build an executable jar (mvn package or gradle bootJar), copy it to the server, run it as a systemd service under its own user so it restarts on crashes and reboots, and put Nginx in front to handle the domain and HTTPS. Keep passwords and database URLs in environment variables, not inside the jar.
1. Build the jar
# Maven
./mvnw clean package -DskipTests
# Gradle
./gradlew bootJar
# the result, e.g. target/app-1.0.0.jar, runs with
java -jar app-1.0.0.jarInstall the same major Java version on the server that you build with. A jar built for Java 21 will not start on Java 17.
2. Run it as a service
# /etc/systemd/system/myapp.service
[Unit]
Description=My Spring Boot app
After=network.target
[Service]
User=myapp
WorkingDirectory=/opt/myapp
EnvironmentFile=/opt/myapp/.env
ExecStart=/usr/bin/java -Xmx512m -jar /opt/myapp/app.jar --server.port=8080
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now myapp
journalctl -u myapp -f # follow the logs3. Put Nginx and HTTPS in front
server {
server_name app.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# then: sudo certbot --nginx -d app.example.comSet server.forward-headers-strategy=framework in Spring Boot so the app knows the original request was HTTPS and builds correct redirect URLs.
Checklist
| Item | Why |
|---|---|
| Own Linux user | A bug in the app cannot touch other sites or system files |
| App listens on 127.0.0.1 only | Visitors go through Nginx and HTTPS, never straight to port 8080 |
| -Xmx set | The JVM stays inside a known memory budget |
| Secrets in an .env file (chmod 600) | Not in the jar or Git |
| Health endpoint monitored | You know when it stops answering |
On GHP Cloud
Create the site as the Java (.jar) type and GHP sets up the Java runtime, an isolated process and the reverse proxy before you upload anything. Drop the jar in through the File Manager and it starts on its own. Environment variables are set in the panel without re-uploading the jar, and the site gets SSL, a custom domain and uptime monitoring like any other site.
Frequently asked questions
Do I need to install Tomcat to run Spring Boot?
No. An executable Spring Boot jar includes its own embedded Tomcat, Jetty or Undertow.
How much RAM does a Spring Boot app need?
Small apps run in 256–512 MB of heap; measure yours under load and leave room for the JVM's overhead beyond -Xmx.
Can I host a WAR file the same way?
A WAR needs a separate servlet container. Rebuilding it as an executable jar is usually simpler.
GHP Team
GHP Cloud
Manage WordPress sites the smart way
GHP Cloud gives you a managed server in India with a firewall, malware scanning and daily backups, billed in INR with a GST invoice — from ₹1,450/month.