Deploy nuxt application on a nginx VPS server running ubuntu

Issue

I am trying to deploy a nuxt blog to a virtual private server that runs nginx.
The blog is supposed to be accessible when I browse to https://exampledomain.com/articles

I have managed to run npm run dev on the server successifully… The app is running on localhost:3000 on the server….

I need to set a reverse proxy on the server to redirect all requests from https://exampledomain.com/articles/ to localhost:3000

I have tried this twice and its failing…. When I browse https://exampledomain.com:3000 the app is loading forever…. when I go to https://exampledomain.com/articles it says "Page not working", or "Internal server error"

Kindly assist

Solution

This could be happening due to incorrect configuration.

Try
sudo nano /etc/nginx/sites-available/your-domain.com

Remember to change the your-domain.com to your desire domain

server {
    listen 80;
    listen [::]:80;
    index index.html;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Answered By – zernonia

Answer Checked By – Terry (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.