Error on Setup nginx to multiples ReactJS app on the same server?

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm building an solution with multiple modules. Each module is a ReactJs app, and i trying config nginx to publish it on the same domain. For examples:



http://application-domain/auth
http://application-domain/admin
http://application-domain/dashboard
http://application-domain/sales



My public directory for nginx stay like this:


|---/var/www

|----/auth

|----/admin

|----/dashboard

|----/sales



where auth, admin, dashboard and sales are subfolders for each projects.



My nginx server conf:



server 
listen 9000 default_server;
listen [::]:9000 default_server;
server_name localhost;

index index.html;

location /
root /var/www/auth;


location /admin
root /var/www;


location /dashboard
root /var/www;


location /sales
root /var/www;




Each project's subfolder has the similar structure like this



enter image description here



The problem is when access http://application-domain/admin, for example, the aplication try to load the static files on root instead subfolder project



GET http://localhost:9000/static/js/main.6314dcaa.js net::ERR_ABORTED


the correct would be get files on admin sub folder like this:



GET http://localhost:9000/admin/static/js/main.6314dcaa.js


What's the better approach to correct nginx configuration for this ?










share|improve this question

























    up vote
    1
    down vote

    favorite












    I'm building an solution with multiple modules. Each module is a ReactJs app, and i trying config nginx to publish it on the same domain. For examples:



    http://application-domain/auth
    http://application-domain/admin
    http://application-domain/dashboard
    http://application-domain/sales



    My public directory for nginx stay like this:


    |---/var/www

    |----/auth

    |----/admin

    |----/dashboard

    |----/sales



    where auth, admin, dashboard and sales are subfolders for each projects.



    My nginx server conf:



    server 
    listen 9000 default_server;
    listen [::]:9000 default_server;
    server_name localhost;

    index index.html;

    location /
    root /var/www/auth;


    location /admin
    root /var/www;


    location /dashboard
    root /var/www;


    location /sales
    root /var/www;




    Each project's subfolder has the similar structure like this



    enter image description here



    The problem is when access http://application-domain/admin, for example, the aplication try to load the static files on root instead subfolder project



    GET http://localhost:9000/static/js/main.6314dcaa.js net::ERR_ABORTED


    the correct would be get files on admin sub folder like this:



    GET http://localhost:9000/admin/static/js/main.6314dcaa.js


    What's the better approach to correct nginx configuration for this ?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm building an solution with multiple modules. Each module is a ReactJs app, and i trying config nginx to publish it on the same domain. For examples:



      http://application-domain/auth
      http://application-domain/admin
      http://application-domain/dashboard
      http://application-domain/sales



      My public directory for nginx stay like this:


      |---/var/www

      |----/auth

      |----/admin

      |----/dashboard

      |----/sales



      where auth, admin, dashboard and sales are subfolders for each projects.



      My nginx server conf:



      server 
      listen 9000 default_server;
      listen [::]:9000 default_server;
      server_name localhost;

      index index.html;

      location /
      root /var/www/auth;


      location /admin
      root /var/www;


      location /dashboard
      root /var/www;


      location /sales
      root /var/www;




      Each project's subfolder has the similar structure like this



      enter image description here



      The problem is when access http://application-domain/admin, for example, the aplication try to load the static files on root instead subfolder project



      GET http://localhost:9000/static/js/main.6314dcaa.js net::ERR_ABORTED


      the correct would be get files on admin sub folder like this:



      GET http://localhost:9000/admin/static/js/main.6314dcaa.js


      What's the better approach to correct nginx configuration for this ?










      share|improve this question













      I'm building an solution with multiple modules. Each module is a ReactJs app, and i trying config nginx to publish it on the same domain. For examples:



      http://application-domain/auth
      http://application-domain/admin
      http://application-domain/dashboard
      http://application-domain/sales



      My public directory for nginx stay like this:


      |---/var/www

      |----/auth

      |----/admin

      |----/dashboard

      |----/sales



      where auth, admin, dashboard and sales are subfolders for each projects.



      My nginx server conf:



      server 
      listen 9000 default_server;
      listen [::]:9000 default_server;
      server_name localhost;

      index index.html;

      location /
      root /var/www/auth;


      location /admin
      root /var/www;


      location /dashboard
      root /var/www;


      location /sales
      root /var/www;




      Each project's subfolder has the similar structure like this



      enter image description here



      The problem is when access http://application-domain/admin, for example, the aplication try to load the static files on root instead subfolder project



      GET http://localhost:9000/static/js/main.6314dcaa.js net::ERR_ABORTED


      the correct would be get files on admin sub folder like this:



      GET http://localhost:9000/admin/static/js/main.6314dcaa.js


      What's the better approach to correct nginx configuration for this ?







      nginx webserver






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 26 at 14:10









      DBs

      61




      61




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I think what you are trying to accomplish can be done by expanding the root section of each location like this:



           location /admin 
          root /var/www/admin;


          location /dashboard
          root /var/www/dashboard;


          location /sales
          root /var/www/sales;



          But that would be the same as only having



          location / 
          root /var/www/



          Since a call to http://application-domain/admin would evaluate to /var/www/admin.



          The first solution would hide anything else in /var/www/ as there is no location rule to access say http://application-domain/private.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464925%2ferror-on-setup-nginx-to-multiples-reactjs-app-on-the-same-server%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            I think what you are trying to accomplish can be done by expanding the root section of each location like this:



             location /admin 
            root /var/www/admin;


            location /dashboard
            root /var/www/dashboard;


            location /sales
            root /var/www/sales;



            But that would be the same as only having



            location / 
            root /var/www/



            Since a call to http://application-domain/admin would evaluate to /var/www/admin.



            The first solution would hide anything else in /var/www/ as there is no location rule to access say http://application-domain/private.






            share|improve this answer
























              up vote
              0
              down vote













              I think what you are trying to accomplish can be done by expanding the root section of each location like this:



               location /admin 
              root /var/www/admin;


              location /dashboard
              root /var/www/dashboard;


              location /sales
              root /var/www/sales;



              But that would be the same as only having



              location / 
              root /var/www/



              Since a call to http://application-domain/admin would evaluate to /var/www/admin.



              The first solution would hide anything else in /var/www/ as there is no location rule to access say http://application-domain/private.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                I think what you are trying to accomplish can be done by expanding the root section of each location like this:



                 location /admin 
                root /var/www/admin;


                location /dashboard
                root /var/www/dashboard;


                location /sales
                root /var/www/sales;



                But that would be the same as only having



                location / 
                root /var/www/



                Since a call to http://application-domain/admin would evaluate to /var/www/admin.



                The first solution would hide anything else in /var/www/ as there is no location rule to access say http://application-domain/private.






                share|improve this answer












                I think what you are trying to accomplish can be done by expanding the root section of each location like this:



                 location /admin 
                root /var/www/admin;


                location /dashboard
                root /var/www/dashboard;


                location /sales
                root /var/www/sales;



                But that would be the same as only having



                location / 
                root /var/www/



                Since a call to http://application-domain/admin would evaluate to /var/www/admin.



                The first solution would hide anything else in /var/www/ as there is no location rule to access say http://application-domain/private.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 26 at 20:55









                linux_pangolin

                764




                764



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464925%2ferror-on-setup-nginx-to-multiples-reactjs-app-on-the-same-server%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    cF9SOHOuQKYc5KOG9kKiWUgha,D6grzkMaeLh8Tv mIj4,cb3hi D,HfBwWC,u9bjWv5qtQ4
                    Z7jFOkfN2Je,Sq ACsYq18,mL RiZ5h8HrH icsDLjpHc18cEj3DCR6JIIo,Z8EDwHn7qSFPVh3fJZH y

                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    How many registers does an x86_64 CPU actually have?

                    Displaying single band from multi-band raster using QGIS