[Ubuntu Server Setup] Lesson 9: Setting Up a Reverse Proxy (Connecting Node.js, Spring Boot, and Flask Services)
![[Ubuntu Server Setup] Lesson 9: Setting Up a Reverse Proxy (Connecting Node.js, Spring Boot, and Flask Services)](/uploads/editor/Ubuntu-서버-구축-9강-Reverse-Proxy-구축하기-Node-js-Spring-Boot-Flask-서비스-연결-20260708-3fb437.webp)
Can Multiple Programs Run Together on One Server?
Hello.
Last time, we learned how to apply HTTPS using Let's Encrypt and set up a free SSL certificate.
Your server is now a secure web server.
However, there's still one question left:
PHP websites are handled directly by Nginx,
but how do you run Node.js, Spring Boot, or Flask services?
The answer is Reverse Proxy.
In this lesson, we'll learn how to operate multiple web services simultaneously on a single Ubuntu Server using Nginx's Reverse Proxy feature.
What Is a Reverse Proxy?
You can think of a Reverse Proxy as an intermediary manager that receives user requests and forwards them to the actual program.
For example, when a user accesses
https://example.com
, Nginx receives the request,
then forwards it to Node.js, Spring Boot, or Flask.
The program processes the request and sends the result back to Nginx,
which then delivers it to the user.
Users don't need to know anything about the internal structure.
Why Use a Reverse Proxy?
Using a Reverse Proxy offers several benefits:
You can run multiple programs simultaneously.
You only need to use one port (80 or 443).
You can manage HTTPS from a single location.
Security is improved.
Server management becomes easier.
This is why most Linux servers use Reverse Proxy configurations.
Problems with the Traditional Approach
For example,
Node.js might use port 3000,
Flask uses port 5000,
and Spring Boot uses port 8080.
If users had to access each service via URLs like
http://example.com:3000
, it would be very inconvenient.
Additionally, setting up HTTPS for each service separately would be required.
How a Reverse Proxy Solves This
Nginx handles incoming requests,
and internally connects to
Node.js
Spring Boot
Flask
automatically.
Users only need to enter
https://example.com
.
In other words,
you can hide all the complex internal structure from users.
How Reverse Proxy Works
The process is straightforward:
① A user accesses via a browser.
↓
② Nginx receives the request.
↓
③ Nginx forwards the request to the internal program.
↓
④ The program processes the task.
↓
⑤ Nginx delivers the result back to the user.
This process happens very quickly.
Connecting Node.js
For example, if a Node.js server is running on
localhost:3000
, Nginx can forward requests to it.
In the configuration file, this is typically set up as:
proxy_pass http://127.0.0.1:3000;
Connecting Flask
Flask works the same way.
If it's running on
127.0.0.1:5000
, Nginx forwards requests to the Flask server.
Users don't need to know which port Flask is using.
Connecting Spring Boot
Spring Boot follows the same principle.
If it's running on
127.0.0.1:8080
, you can access it via
https://example.com
using a Reverse Proxy.
This method is widely used in real-world enterprise environments.
Running Multiple Services on One Server
For example,
blog.example.com
could point to PHP,
api.example.com
to Node.js,
admin.example.com
to Spring Boot,
ai.example.com
to Flask.
All of these can run on a single Ubuntu Server.
Reverse Proxy and HTTPS
One major advantage is simplified HTTPS management.
You only need to apply SSL certificates to Nginx.
No separate SSL setup is required for Node.js or Flask.
Nginx handles all HTTPS processing,
making management much more convenient.
Reverse Proxy and Firewalls
Externally, you only need to open ports 80 and 443.
There's no need to expose internal ports like:
Node.js on port 3000
Flask on port 5000
Spring Boot on port 8080
This improves security significantly.
Reverse Proxy and Performance
Nginx handles static files very efficiently,
such as:
Images
CSS
JavaScript
while more complex tasks like API processing are handled by Node.js or Spring Boot.
By letting each program focus on what it does best, server performance improves.
Real-World Server Architecture
In practice, many servers use this setup:
Ubuntu Server
↓
Nginx
↓
PHP
↓
Node.js
↓
Spring Boot
↓
Flask
↓
MySQL
This allows multiple technologies to work together within a single server.
Why Reverse Proxy Is Important
Modern web services often combine multiple technologies,
rather than relying on just one language.
For example, you might have:
A PHP-based website for the front end,
a Node.js API backend,
a Spring Boot admin panel,
and a Flask-powered AI service.
The Reverse Proxy enables all these services to run smoothly on one server.
Common Mistakes
If your service doesn't load after setting up the Reverse Proxy, check:
Whether the program is running
The correct port number
Nginx configuration correctness
Accuracy of the proxy_pass address
Firewall settings
Most issues can be resolved by verifying these five points.
What We Learned Today
In this lesson, we explored the concept and operation of Reverse Proxy and learned how to run Node.js, Spring Boot, and Flask services on a single Ubuntu Server.
Reverse Proxy is nearly essential for modern web services.
Understanding this feature allows you to efficiently manage various development environments on one server.
Key Takeaways
A Reverse Proxy forwards user requests to internal programs.
You can run multiple web services simultaneously on one server.
Node.js, Spring Boot, and Flask can be easily connected.
HTTPS only needs to be configured once in Nginx.
No need to expose internal ports externally for better security.
Reverse Proxy is the most commonly used configuration in real server environments.
Next Lesson Preview
10th Lesson: Securing Your Server with UFW Firewall, Fail2Ban, and SSH Security Settings
In the next lesson, we'll cover essential security settings for Ubuntu servers, including configuring the UFW firewall, installing Fail2Ban, and enhancing SSH security through practical exercises.
FAQ
What is a Reverse Proxy?
A Reverse Proxy acts as an intermediary that receives user requests and forwards them to the appropriate internal program, hiding complex internal structures from users.
Why use a Reverse Proxy for multiple services?
It allows you to run several web services on one server using a single port (80/443), manage HTTPS centrally, improve security by not exposing internal ports, and simplify server management.
Korean Source
This article is an English localization of a Korean-language report from BlogScore. Original: [Ubuntu 서버 구축] 9강. Reverse Proxy 구축하기 (Node.js, Spring Boot, Flask 서비스 연결)