Display static html file on /register





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I have a web app (boilerplated with VueJS CLI) running on nginx.



All requests to this app (except /api) are handled by root index.html (since it's using frontend-side routing). I want add another exception to this rule, so that when we go to /register it redirects us to some other static public html file (not related with this VueJS app, but sitting under the same project/directory).



In other words, I want to redirect /register to /public/xyz/index.html but without changing the URL displayed in the browser address bar.



I tried to add location = /register rule but it doesn't seem to work, on /register it still keeps redirecting me to /app/dist/index.html.



My nginx.conf:



server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /app/dist;
index index.html;

server_name localhost;

location = /register {
root /public/xyz;
index index.html
}
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control no-cache;
expires 0;
}
location ~ ^/api/(.*) {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass_request_headers on;

proxy_pass <ENV_API_URL>/$1$is_args$args;
}
}










share|improve this question





























    2















    I have a web app (boilerplated with VueJS CLI) running on nginx.



    All requests to this app (except /api) are handled by root index.html (since it's using frontend-side routing). I want add another exception to this rule, so that when we go to /register it redirects us to some other static public html file (not related with this VueJS app, but sitting under the same project/directory).



    In other words, I want to redirect /register to /public/xyz/index.html but without changing the URL displayed in the browser address bar.



    I tried to add location = /register rule but it doesn't seem to work, on /register it still keeps redirecting me to /app/dist/index.html.



    My nginx.conf:



    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /app/dist;
    index index.html;

    server_name localhost;

    location = /register {
    root /public/xyz;
    index index.html
    }
    location / {
    try_files $uri $uri/ /index.html;
    add_header Cache-Control no-cache;
    expires 0;
    }
    location ~ ^/api/(.*) {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass_request_headers on;

    proxy_pass <ENV_API_URL>/$1$is_args$args;
    }
    }










    share|improve this question

























      2












      2








      2








      I have a web app (boilerplated with VueJS CLI) running on nginx.



      All requests to this app (except /api) are handled by root index.html (since it's using frontend-side routing). I want add another exception to this rule, so that when we go to /register it redirects us to some other static public html file (not related with this VueJS app, but sitting under the same project/directory).



      In other words, I want to redirect /register to /public/xyz/index.html but without changing the URL displayed in the browser address bar.



      I tried to add location = /register rule but it doesn't seem to work, on /register it still keeps redirecting me to /app/dist/index.html.



      My nginx.conf:



      server {
      listen 80 default_server;
      listen [::]:80 default_server ipv6only=on;

      root /app/dist;
      index index.html;

      server_name localhost;

      location = /register {
      root /public/xyz;
      index index.html
      }
      location / {
      try_files $uri $uri/ /index.html;
      add_header Cache-Control no-cache;
      expires 0;
      }
      location ~ ^/api/(.*) {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass_request_headers on;

      proxy_pass <ENV_API_URL>/$1$is_args$args;
      }
      }










      share|improve this question














      I have a web app (boilerplated with VueJS CLI) running on nginx.



      All requests to this app (except /api) are handled by root index.html (since it's using frontend-side routing). I want add another exception to this rule, so that when we go to /register it redirects us to some other static public html file (not related with this VueJS app, but sitting under the same project/directory).



      In other words, I want to redirect /register to /public/xyz/index.html but without changing the URL displayed in the browser address bar.



      I tried to add location = /register rule but it doesn't seem to work, on /register it still keeps redirecting me to /app/dist/index.html.



      My nginx.conf:



      server {
      listen 80 default_server;
      listen [::]:80 default_server ipv6only=on;

      root /app/dist;
      index index.html;

      server_name localhost;

      location = /register {
      root /public/xyz;
      index index.html
      }
      location / {
      try_files $uri $uri/ /index.html;
      add_header Cache-Control no-cache;
      expires 0;
      }
      location ~ ^/api/(.*) {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass_request_headers on;

      proxy_pass <ENV_API_URL>/$1$is_args$args;
      }
      }







      nginx






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 30 at 12:33









      van_folmertvan_folmert

      121115




      121115






















          1 Answer
          1






          active

          oldest

          votes


















          5














          You should use an alias instead, to substitute directly for the path you want.



          location = /register {
          alias /public/xyz/index.html;
          }





          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "2"
            };
            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f951497%2fdisplay-static-html-file-on-register%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            You should use an alias instead, to substitute directly for the path you want.



            location = /register {
            alias /public/xyz/index.html;
            }





            share|improve this answer




























              5














              You should use an alias instead, to substitute directly for the path you want.



              location = /register {
              alias /public/xyz/index.html;
              }





              share|improve this answer


























                5












                5








                5







                You should use an alias instead, to substitute directly for the path you want.



                location = /register {
                alias /public/xyz/index.html;
                }





                share|improve this answer













                You should use an alias instead, to substitute directly for the path you want.



                location = /register {
                alias /public/xyz/index.html;
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 30 at 13:15









                Michael HamptonMichael Hampton

                174k27319644




                174k27319644






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Server Fault!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f951497%2fdisplay-static-html-file-on-register%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                    ts Property 'filter' does not exist on type '{}'

                    mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window