Static GitHub Issues

[2131] Setting Up Nuxt With Nginx

prev: axios proxy has error
next: Validate several pages with similar routes

Hello,

I've been facing problems when serving only the nuxt .js files through Nginx.

Well, I have a subdomain subdomain.domain.com that runs a wordpress blog and e-commerce. However, I intend to serve nuxt on a specific location of this subdomain, something like subdomain.domain.com /nuxtproject

Here is my nginx conf

server {
    # SSL configuration
        listen 443 ssl;
       server_name subdomain.domain.com.br;

        ssl on;
        ssl_certificate /etc/nginx/ssl/certs/ssl.crt;
        ssl_certificate_key /etc/nginx/ssl/private/certificate.key;

    root /var/www/html/cursosabertosv2;

    location /pay {
      alias /var/www/html/crescimentum.pay/source;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $host;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_pass http://localhost:3000;
}

location / {
      root /var/www/html/cursosabertosv2;
      index index.php index.html index.htm;
      set $php_root /var/www/html/cursosabertosv2;
      try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
      root /var/www/html/cursosabertosv2;
      index index.php index.html index.htm;
      set $php_root /var/www/html/cursosabertosv2;
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/run/php/php7.0-fpm.sock;
 }


    location = /favicon.ico { root /var/www/html/cursosabertosv2; log_not_found off; access_log off; }
    location = /robots.txt { root /var/www/html/cursosabertosv2; log_not_found off; access_log off; allow all; }

    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        add_header Access-Control-Allow-Origin "*";
    }

}

https://subdomain.domain.com.br/nuxtProject/nuxtBuild/dist/app.eef42378ecb0188c013a.js error 404 not found

** I am using nuxt build, with the build Path set to nuxtBuild

Can someone help me please ?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1889">#c1889</a>)</em></sub></div>