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;
}
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
add a comment |
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
add a comment |
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
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
nginx
asked Jan 30 at 12:33


van_folmertvan_folmert
121115
121115
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You should use an alias
instead, to substitute directly for the path you want.
location = /register {
alias /public/xyz/index.html;
}
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You should use an alias
instead, to substitute directly for the path you want.
location = /register {
alias /public/xyz/index.html;
}
add a comment |
You should use an alias
instead, to substitute directly for the path you want.
location = /register {
alias /public/xyz/index.html;
}
add a comment |
You should use an alias
instead, to substitute directly for the path you want.
location = /register {
alias /public/xyz/index.html;
}
You should use an alias
instead, to substitute directly for the path you want.
location = /register {
alias /public/xyz/index.html;
}
answered Jan 30 at 13:15


Michael Hampton♦Michael Hampton
174k27319644
174k27319644
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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