blog 8 How to Run Your App Like a Background Service (Even After Reboot!) – DevSecOps for Beginners

Blog 8 - How to Run Your App Like a Service | By Kalyan

✅ Blog 8: How to Make Your App Run Like a Service (For Beginners)

Hello! In this blog, we will learn how to make your app run in the background like a service. We will also learn what Nginx and proxies are — in a very simple way!

🔸 What is a Service?

A service is something that runs all the time — like a fan in your room. Even when you restart your system, it starts again. We can do the same with our app using a .service file.

🔧 How to Create a Service File

Let’s say your app is a Node.js app. We can create a service like this:

vim /etc/systemd/system/backend.service

Add this inside:

[Unit]
Description = My Backend App

[Service]
User=expense
Environment=DB_HOST="172.31.85.250"
ExecStart=/bin/node /app/index.js
SyslogIdentifier=backend

[Install]
WantedBy=multi-user.target

That’s it! Now run these commands to start the service:

systemctl daemon-reexec
systemctl daemon-reload
systemctl enable backend
systemctl start backend
systemctl status backend

🌐 What is a Public IP and Private IP?

Type Example Use
Public IP 49.204.161.202 Used to access from the internet
Private IP 192.168.0.107 Used only inside local network

🌐 What is Nginx?

Nginx is a tool that helps send people to the right app. It also protects your app by hiding it.

🔁 What is a Proxy?

A proxy is like a middleman.

Type Used by Why?
Forward Proxy (like VPN) Client knows To hide the user
Reverse Proxy (like Nginx) Server knows To hide backend apps

🔐 Example Nginx Config

This is what Nginx config may look like:

proxy_http_version 1.1;

location /api/ {
  proxy_pass http://172.31.88.35:8080/;
}

location /health {
  stub_status on;
  access_log off;
}

📂 Nginx Folder Locations

Path What it does
/etc/nginx Main Nginx folder
/etc/nginx/nginx.conf Main Nginx config file
/usr/share/nginx/html Website folder

🚀 Want to Practice?

You can use this ready AWS DevOps image to practice:

https://github.com/learndevopsonline/aws-image-devops-session.git

✅ Final Summary

  • Use a .service file to make your app run all the time
  • Know the difference between public and private IP
  • Use Nginx to protect and forward requests to your backend app
  • Understand what proxies do — forward proxy hides clients, reverse proxy hides servers

Written by: Kalyan Kalavena | DevSecOps Blog #8 (Simple Version)

Comments

Popular Posts