Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Configuring Domain Names for Node.js, Vue SPA, and SSR Applications

Tech 2

Domain Name Registration

Register a domain name through a domain registrar such as Tencent Cloud.

DNS Record Configuration

Configure DNS records in your domain management panel to point the domain to your server's IP address.

Nginx Server Block Setup

Naivgate to the Nginx configuration directroy:

cd /usr/local/lighthouse/softwares/nginx/conf/web

Vue Single-Page Application Configuration

server {
    listen 80;
    server_name admin.example.com;
    charset utf-8;
    
    location / {
        root /home/node/nodejs-koa-blog/admin-blog/dist;
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }
}

Server-Side Rendered Application Configuration

server {
    listen 80;
    server_name blog.example.com;
    
    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Nginx-Proxy true;
        proxy_cache_bypass $http_upgrade;
        proxy_pass http://localhost:3001/;
    }
}

Node.js API Service Configuration

server {
    listen 80;
    server_name api.example.com;
    
    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Nginx-Proxy true;
        proxy_cache_bypass $http_upgrade;
        proxy_pass http://localhost:9000/;
    }
}

Nginx Configuration Validation

Test the configuration syntax:

nginx -t

Reload Nginx to apply changes:

nginx -s reload

Access Verification

Verify the appplications are accessible via their respective domains:

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.