fix remain html code 01

This commit is contained in:
NAS\NASPC
2026-06-07 16:06:50 +07:00
parent 109c09d2a3
commit 0f551bd5c7
14 changed files with 3246 additions and 2631 deletions
+57 -36
View File
@@ -186,46 +186,67 @@ To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`)
- [Node.js](https://nodejs.org/)
- [NPM](https://www.npmjs.com/)
#Structure
## Deployment Guide (Ubuntu server + aaPanel + Docker)
Using NGINX (via aaPanel) with Tomcat is a very common and recommended setup. In this architecture, NGINX acts as a Reverse Proxy. It handles incoming internet traffic (ports 80 and 443 for SSL) and forwards the requests to your Tomcat application running in the background (usually on port 8080).
### 1. Build the WAR file (on Windows)
To deploy this application to an external Tomcat server, you need to build a `.war` file.
Run the following command on your Windows PC to build the production-ready `.war` file:
```powershell
./gradlew -Pprod -Pwar clean bootWar
```
Alternatively, you can use the built-in npm script:
```powershell
npm run java:war:prod
```
The generated `.war` file will be located at `build/libs/sisvietnamvn-0.0.1-SNAPSHOT.war`.
Here is the step-by-step guide to setting this up in aaPanel:
### 2. Standalone Tomcat 10 using Docker Compose (on Ubuntu Server)
Since this project uses Java 21, it requires **Tomcat 10.1**. You can set this up on your Ubuntu server using Docker Compose.
Step 1: Start your Tomcat/Spring Boot App
Make sure your application is running. By default, your project seems to run on port 8080.
Create a folder for Tomcat, and add a `docker-compose.yml` file:
```yaml
version: '3.8'
If using embedded Tomcat: Run your .jar file in the background (e.g., nohup java -jar your-app.jar --spring.profiles.active=prod &).
If using standalone Tomcat: Ensure Tomcat is started and the app is deployed.
Step 2: Configure the Website in aaPanel
Log in to your aaPanel dashboard.
Go to the Website menu on the left sidebar.
Click Add site (if you haven't already).
Enter your domain name (e.g., sisvietnam.vn).
For PHP version, select Static (since Java handles the backend, you don't need PHP).
Click Submit to create the site.
Step 3: Set up the Reverse Proxy
In the Website list, click on the Settings button for your newly created domain.
In the settings window, click on the Reverse proxy tab on the left.
Click Add reverse proxy and fill in the details:
Proxy name: Give it any name (e.g., TomcatProxy).
Target URL: Enter http://127.0.0.1:8080 (Change 8080 if your app is running on a different port).
Sent Domain: Leave it as $host (the default).
Click Submit.
Step 4: Configure Spring Boot to Trust the Proxy (Crucial)
Because NGINX sits in front of your app, Tomcat will think all requests are coming from 127.0.0.1 instead of the user's real IP, and it might get confused about http vs https (which breaks redirects and security).
services:
tomcat:
image: tomcat:10.1-jdk21
container_name: my-tomcat-server
ports:
- "8080:8080"
environment:
- TZ=Asia/Ho_Chi_Minh
volumes:
- ./webapps:/usr/local/tomcat/webapps
- ./logs:/usr/local/tomcat/logs
restart: unless-stopped
```
To fix this, you need to tell your Spring Boot app to read the headers forwarded by NGINX. Open your src/main/resources/config/application-prod.yml (or application.yml) and add:
Create the required folders and start the server:
```bash
mkdir webapps logs
docker compose up -d
```
yaml
server:
forward-headers-strategy: framework
(Note: JHipster usually configures this automatically for the prod profile, but it is good to double-check).
### 3. Deploy the application
After running the build command successfully, your .war file is located here:
d:\website_sisvietnam_moi\website_sisvietnam.vn\sisvietnamvn\build\libs\sisvietnamvn-0.0.1-SNAPSHOT.war
(Inside your project folder, look for the build folder, then open the libs folder).
This sisvietnamvn-0.0.1-SNAPSHOT.war file is the one you need to upload to your Ubuntu server and rename to ROOT.war inside the Tomcat webapps folder.
Summary of How it Works Now:
A user visits https://your-domain.com.
NGINX (aaPanel) receives the request on port 443.
NGINX forwards the request to http://127.0.0.1:8080.
Tomcat (Java) processes the request and sends the HTML/JSON back to NGINX.
NGINX sends the response back to the user.
You can also use aaPanel's built-in SSL manager to easily apply Let's Encrypt certificates to your NGINX site, and your Tomcat backend won't need to worry about SSL certificates at all!
Upload the `.war` file you built in Step 1 to the server.
Place it inside the `webapps/` folder you just created and rename it to `ROOT.war` (so it serves on the root path `/`). Tomcat will automatically detect and deploy it.
### 4. Configure NGINX Reverse Proxy (aaPanel)
Using NGINX (via aaPanel) with Tomcat is a highly recommended setup. NGINX acts as a Reverse Proxy, handling internet traffic (ports 80 and 443 for SSL) and forwarding it to Tomcat on port 8080.
1. **Add Site**: Go to aaPanel -> Website -> Add site. Enter your domain (e.g., `sisvietnam.vn`) and select **Static** for the PHP version.
2. **Setup Reverse Proxy**: Click "Settings" for the new site -> "Reverse proxy" -> "Add reverse proxy".
- **Proxy name**: `TomcatProxy`
- **Target URL**: `http://127.0.0.1:8080`
- **Sent Domain**: `$host`
3. **Spring Boot Proxy Trust**: Ensure Spring Boot knows it is behind a proxy so it can read client IPs and HTTP schemes correctly. In `src/main/resources/config/application-prod.yml`, verify this exists:
```yaml
server:
forward-headers-strategy: framework
```
4. **SSL**: Use aaPanel's built-in SSL manager to apply Let's Encrypt certificates to your NGINX site. Your Tomcat backend won't need to worry about SSL certificates.