P
P
postya2020-11-14 08:21:30
Nginx
postya, 2020-11-14 08:21:30

How to properly deploy nuxt application on linux server?

There is an application on Nuxt. On my local computer, it opens successfully and all resources are shown
The application is deployed here:
glinka.tk
When I deployed to a linux server, the application is displayed, but no resources were found, and an error appears:
5faf673a5159e435421822.jpeg

What did I do wrong when deploying? and how to fix it?

All resources are loaded from this folder:
5faf677e7480c565541753.jpeg

I connect images like this:

<img src="../assets/images/my-works-bg.webp" alt="works-bg" />

I also tried this: How I did the deployment: 1. Cloned the project to the server 2. Installed the dependencies - yarn install 3. Made the project build: yarn run build 4. Created a config file for nginx:
<img src="~/assets/images/avatar.webp" alt="" />

server {

    listen 80;

    server_name glinka.tk  www.glinka.tk;
    index index.html index.htm;

    location /_nuxt/ {
    alias /home/kentforth/webapps/Glinka-Frontend-Nuxt/.nuxt/dist/;
  }
    location / {
       proxy_pass http://localhost:6050;
       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;
    }

    error_log  /var/log/nginx/glinka-frontend-error.log;
    access_log /var/log/nginx/glinka-frontend-access.log;
}


4. Launched the application via pm2
pm2 start npm --name "glinka-frontend" -- start

5faf68c3004b9165652544.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Darhild, 2020-11-14
@postya

I'm not an nginx expert, but I think the redirect for /_nuxt/ is superfluous here. A proxy_pass is enough for the port on which nuxt starts - in any case, everything works without problems for us in this way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question