Static GitHub Issues

[1609] Javascript losed when put behind nginx with subdirectory

prev: Blank Screen with SPA mode and Apollo Module
next: example auth-routes not working

when I don't use nginx,html have script: <script type="text/javascript" charset="utf-8" async="" src="/home/_nuxt/pages/meun.5be99cbccd5537efbb30.js"></script>

when I use nginx, this script is losed!

my nginx.conf is:

nginx.conf:

#user  nobody;
user  root;
worker_processes  4;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#
#pid        logs/nginx.pid;

worker_rlimit_nofile 204800;

events {
  worker_connections  65535;
  multi_accept  on;
  use  epoll;
}

http {
    include       mime.types;
    default_type text/html;
    charset UTF-8;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  off;
    server_tokens  off;
    sendfile  on;
    tcp_nopush  on;
    tcp_nodelay  on;

    #keepalive_timeout  0;
    keepalive_timeout 30;
    client_header_timeout 10;
    client_body_timeout 20;
    reset_timedout_connection on;
    send_timeout 10;

                                                                                                                                                      30,1         顶端
    send_timeout 10;

    #代理和缓存设置
    proxy_connect_timeout 120;
    proxy_read_timeout 120;
    proxy_send_timeout 60;
    proxy_buffer_size 16k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;
    #proxy_temp_path /home/temp_dir;
    #proxy_cache_path /home/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
    #proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;

    #gzip 配置
    gzip on;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 1000;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;


    open_file_cache max=100000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    include /usr/local/nginx/conf.d/*.conf;
}

subdirectory conf is:

server {
        listen  80;
        server_name  zhdj.myun.info;
        charset utf8;
        access_log  logs/zhdj.myun.info.log main;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
                proxy_pass http://127.0.0.1:3000;
        }

        location ~* /home/ {
                rewrite /home/_nuxt/(.*)$ /home/_nuxt/$1 break;
                rewrite /home/(.*)$ /$1 break;
                proxy_pass http://127.0.0.1:3001;
        }

        location ~* /setting/ {
                rewrite /setting/_nuxt/(.*)$ /setting/_nuxt/$1 break;
                rewrite /setting/(.*)$ /$1 break;
                proxy_pass http://127.0.0.1:3001;
        }
}
<!--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/c1437">#c1437</a>)</em></sub></div>