最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

nginx - serving multipe static file directory with multiple next.js apps - Stack Overflow

programmeradmin1浏览0评论

English is not my native language.

I have three Next.js apps, each with their own static file directory(.next) and I want to config Nginx the way it find the required static files.

here is my current Nginx config.

    location /_next {
            alias /.../users-front/.next;
    }   
    location /fonts {
            alias /.../users-front/public/fonts;
    }   


    location /{
        include proxy_params;
        #proxy_pass http://unix:/run/gunicorn.sock;
        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;
    }   

    location /doctors {
        rewrite ^/doctors/(.*)$ /$1 break;
        include proxy_params;
        #proxy_pass http://unix:/run/gunicorn.sock;
        proxy_pass http://localhost:3001;
        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;
    }   

    location /users {
        rewrite ^/users/(.*)$ /$1 break;
        include proxy_params;
        #proxy_pass http://unix:/run/gunicorn.sock;
        proxy_pass http://localhost:3002;
        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;                                                                                                                                                    
    }  

I'm not a frontend developer or senior devops, I have to do this and I don't know how!

the three apps are named "users-front", "authors-front" and "landing". all of them send static file requests to /_next.

I tried this and it didn't work

    location /_next {
        try_files $uri 
            /path/to/app1/.next$uri 
            /path/to/app2/.next$uri 
            /path/to/app3/.next$uri 
            =404; # Return 404 if not found in any location
    }
发布评论

评论列表(0)

  1. 暂无评论