nuxt/framework

Nuxt 3 don't work with Nginx + SSL on my VPS

rah-emil opened this issue · 2 comments

Environment

/www/site.com$ npx nuxi info
Nuxt CLI v3.0.0-rc.8 19:09:12
RootDir: /var/www/develop_site_usr/data/www/site.com 19:09:20
Nuxt project info: 19:09:20


  • Operating System: Linux
  • Node Version: v16.16.0
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: npm@8.11.0
  • Builder: vite
  • User Config: vite
  • Runtime Modules: -
  • Build Modules: -

Reproduction

  1. cd /www/site.com
  2. npx nuxi build

My Nginx config (*IP SERVER* - my hidden server IP):

server {
    server_name site.com;

    charset utf-8;
    listen *IP SERVER*:443 ssl  http2 ;

    ssl_certificate "/var/www/httpd-cert/site.com_2022-08-22-12-52_02.crt";
    ssl_certificate_key "/var/www/httpd-cert/site.com_2022-08-22-12-52_02.key";

    gzip on;
    gzip_min_length 1024;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/css image/x-ico application/pdf image/jpeg image/png image/gif application/javascript application/x-javascript application/x-pointplus;
    gzip_comp_level 5;

    set $root_path /var/www/develop_site_usr/data/www/site.com;

    root $root_path;
    disable_symlinks if_not_owner from=$root_path;

    location / {

        index index.html;
    }


    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpeg|avi|zip|gz|bz2|rar|swf|ico|7z|doc|docx|map|ogg|otf|pdf|tff|tif|txt|wav|webp|woff|woff2|xls|xlsx|xml)$ {
        try_files $uri $uri/ =404;
    }


    include "/etc/nginx/fastpanel2-sites/develop_site_usr/site.com.includes";
    include /etc/nginx/fastpanel2-includes/*.conf;
    error_log /var/www/develop_site_usr/data/logs/site.com-frontend.error.log;

    access_log /var/www/develop_site_usr/data/logs/site.com-frontend.access.log;

}


server {
    server_name site.com;

    listen *IP SERVER*:80;
    return 301 https://$host$request_uri;

    error_log /var/www/develop_site_usr/data/logs/site.com-frontend.error.log;
    access_log /var/www/develop_site_usr/data/logs/site.com-frontend.access.log;
}


server {
    server_name www.site.com  ;

    listen *IP SERVER*:80;
    listen *IP SERVER*:443 ssl http2 ;

    ssl_certificate "/var/www/httpd-cert/site.com_2022-08-22-12-52_02.crt";
    ssl_certificate_key "/var/www/httpd-cert/site.com_2022-08-22-12-52_02.key";

    return 301 $scheme://site.com$request_uri;

    error_log /var/www/develop_site_usr/data/logs/site.com-frontend.error.log;
    access_log /var/www/develop_site_usr/data/logs/site.com-frontend.access.log;
}

Describe the bug

403 Forbidden
nginx/1.22.0

Additional context

I have tried these solutions: nuxt/nuxt#12003.
didn't help me...🙄

Logs

Logs with 403 (`*MY IP*` - my hidden ip):

*MY IP* - - [22/Aug/2022:19:18:19 +0000] "GET / HTTP/2.0" 403 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"

Logs when I tried to solve it like this nuxt/nuxt#12003:

*MY IP* - - [22/Aug/2022:19:06:04 +0000] "GET / HTTP/2.0" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"

Yes, I tried that too, it didn't work (err 502):

# nginx
location /_nuxt/hmr/ {
        proxy_pass http://localhost:24678;
        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;
}
// nuxt.config.ts
import { defineNuxtConfig } from 'nuxt'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  vite: {
    server: {
      hmr: {
        protocol: "wss",
        clientPort: 443,
        path: "hmr/",
      },
    },
  },
})

And I don't use any of the above https://v3.nuxtjs.org/guide/deploy/presets#supported-hosting-providers. How can I run a project on my server? I have my own VPS server