Nginx rewrite response in reverse proxy to point back to initial locationPort Routing/DNS for individual...
Thousands and thousands of words
Rotated Position of Integers
Why would Lupin kill Pettigrew?
count number of files in directory with a certain name
How to properly maintain eye contact with people that have distinctive facial features?
How to detach yourself from a character you're going to kill?
Is there an evolutionary advantage to having two heads?
Socratic Paradox
Is having a hidden directory under /etc safe?
chmod would set file permission to 000 no matter what permission i try to set
What are the benefits of cryosleep?
What caused the tendency for conservatives to not support climate change regulations?
What is the intuition behind uniform continuity?
Why is there a need to modify system call tables in linux?
Infinitely many hats
Is it possible to change original filename of an exe?
Future enhancements for the finite element method
Can non-English-speaking characters use wordplay specific to English?
What does it mean when you think without speaking?
Asking bank to reduce APR instead of increasing credit limit
Can a wire having a 610-670 THz (frequency of blue light) AC frequency supply, generate blue light?
Is the world in Game of Thrones spherical or flat?
When was the expression "Indian file" first used in English?
In what episode of TOS did a character on the bridge make a comment about raising the number 1 to some power?
Nginx rewrite response in reverse proxy to point back to initial location
Port Routing/DNS for individual programNGINX Reverse Proxy - no user/password was provided for basic authenticationOpposite behavior of keepalive (nginx reverse proxy on ElasticSearch)Running NGINX as a Reverse Proxy on Docker?Nginx Reverse Proxy setupnginx reverse proxy: host not allowed errorRedirect request to corporate proxy server with nginx reverse proxyNginx reverse TCP handler to stunnelNginx reverse proxy - .js and .css forbiddenRedirect on the same port from http to https with nginx reverse proxy
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Problem
Smart apps - solution exists
Lots of applications have the concept of a "context path" which allows them to run easily behind a reverse proxy. The configuration for this would be simple:
location /myApp/ {
proxy_pass http://app-server:10000/myApp;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Dumb apps - solution unknown?
Now lets assume we have an app that isn't proxy aware, and it expects to find its static resources at /images, /js, etc. This app also listens at the root path:
proxy_pass http://app-server:10000/;
If you were to run this same configuration, you would receive a 200 code on your first initial request, and then a 404 for each subsequent request. The initial matching of the /myApp/ needs to be prepended to each path in every request for it to work. We essentially need to handle the correct URL transformations ourselves because the app isn't smart enough.
The following is a config that doesn't work, but is something similar to what I expect the correct configuration would look like:
location ~ /myApp/(.*)$ {
proxy_pass http://app-server:10000/$1;
proxy_redirect http://app-server:10000/ $scheme://$host:$server_port/myApp/$1;
...
}
What configuration would be required to prepend to the path so that the URL gets correctly resolved? I feel like using map would be useful somewhere here, but I don't know enough Nginx internals on how the proxy communicates with the upstream server.
Mini Rant
This is certainly NOT a duplicate of any previous questions. You can find numerous questions similar to this, but not one of them sufficiently solves this problem. It seems clear to me that this would be a common problem for anyone running a reverse proxy in an Enterprise network as I have encountered it many times, yet Nginx doesn't provide a clear solution to it.
path nginx proxy rewrite
add a comment |
Problem
Smart apps - solution exists
Lots of applications have the concept of a "context path" which allows them to run easily behind a reverse proxy. The configuration for this would be simple:
location /myApp/ {
proxy_pass http://app-server:10000/myApp;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Dumb apps - solution unknown?
Now lets assume we have an app that isn't proxy aware, and it expects to find its static resources at /images, /js, etc. This app also listens at the root path:
proxy_pass http://app-server:10000/;
If you were to run this same configuration, you would receive a 200 code on your first initial request, and then a 404 for each subsequent request. The initial matching of the /myApp/ needs to be prepended to each path in every request for it to work. We essentially need to handle the correct URL transformations ourselves because the app isn't smart enough.
The following is a config that doesn't work, but is something similar to what I expect the correct configuration would look like:
location ~ /myApp/(.*)$ {
proxy_pass http://app-server:10000/$1;
proxy_redirect http://app-server:10000/ $scheme://$host:$server_port/myApp/$1;
...
}
What configuration would be required to prepend to the path so that the URL gets correctly resolved? I feel like using map would be useful somewhere here, but I don't know enough Nginx internals on how the proxy communicates with the upstream server.
Mini Rant
This is certainly NOT a duplicate of any previous questions. You can find numerous questions similar to this, but not one of them sufficiently solves this problem. It seems clear to me that this would be a common problem for anyone running a reverse proxy in an Enterprise network as I have encountered it many times, yet Nginx doesn't provide a clear solution to it.
path nginx proxy rewrite
I wanted to move this to serverfault, but stackoverflow made it hard to do. oh well
– Luke Pafford
1 hour ago
add a comment |
Problem
Smart apps - solution exists
Lots of applications have the concept of a "context path" which allows them to run easily behind a reverse proxy. The configuration for this would be simple:
location /myApp/ {
proxy_pass http://app-server:10000/myApp;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Dumb apps - solution unknown?
Now lets assume we have an app that isn't proxy aware, and it expects to find its static resources at /images, /js, etc. This app also listens at the root path:
proxy_pass http://app-server:10000/;
If you were to run this same configuration, you would receive a 200 code on your first initial request, and then a 404 for each subsequent request. The initial matching of the /myApp/ needs to be prepended to each path in every request for it to work. We essentially need to handle the correct URL transformations ourselves because the app isn't smart enough.
The following is a config that doesn't work, but is something similar to what I expect the correct configuration would look like:
location ~ /myApp/(.*)$ {
proxy_pass http://app-server:10000/$1;
proxy_redirect http://app-server:10000/ $scheme://$host:$server_port/myApp/$1;
...
}
What configuration would be required to prepend to the path so that the URL gets correctly resolved? I feel like using map would be useful somewhere here, but I don't know enough Nginx internals on how the proxy communicates with the upstream server.
Mini Rant
This is certainly NOT a duplicate of any previous questions. You can find numerous questions similar to this, but not one of them sufficiently solves this problem. It seems clear to me that this would be a common problem for anyone running a reverse proxy in an Enterprise network as I have encountered it many times, yet Nginx doesn't provide a clear solution to it.
path nginx proxy rewrite
Problem
Smart apps - solution exists
Lots of applications have the concept of a "context path" which allows them to run easily behind a reverse proxy. The configuration for this would be simple:
location /myApp/ {
proxy_pass http://app-server:10000/myApp;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Dumb apps - solution unknown?
Now lets assume we have an app that isn't proxy aware, and it expects to find its static resources at /images, /js, etc. This app also listens at the root path:
proxy_pass http://app-server:10000/;
If you were to run this same configuration, you would receive a 200 code on your first initial request, and then a 404 for each subsequent request. The initial matching of the /myApp/ needs to be prepended to each path in every request for it to work. We essentially need to handle the correct URL transformations ourselves because the app isn't smart enough.
The following is a config that doesn't work, but is something similar to what I expect the correct configuration would look like:
location ~ /myApp/(.*)$ {
proxy_pass http://app-server:10000/$1;
proxy_redirect http://app-server:10000/ $scheme://$host:$server_port/myApp/$1;
...
}
What configuration would be required to prepend to the path so that the URL gets correctly resolved? I feel like using map would be useful somewhere here, but I don't know enough Nginx internals on how the proxy communicates with the upstream server.
Mini Rant
This is certainly NOT a duplicate of any previous questions. You can find numerous questions similar to this, but not one of them sufficiently solves this problem. It seems clear to me that this would be a common problem for anyone running a reverse proxy in an Enterprise network as I have encountered it many times, yet Nginx doesn't provide a clear solution to it.
path nginx proxy rewrite
path nginx proxy rewrite
edited 1 hour ago
Luke Pafford
asked 1 hour ago
Luke PaffordLuke Pafford
1067
1067
I wanted to move this to serverfault, but stackoverflow made it hard to do. oh well
– Luke Pafford
1 hour ago
add a comment |
I wanted to move this to serverfault, but stackoverflow made it hard to do. oh well
– Luke Pafford
1 hour ago
I wanted to move this to serverfault, but stackoverflow made it hard to do. oh well
– Luke Pafford
1 hour ago
I wanted to move this to serverfault, but stackoverflow made it hard to do. oh well
– Luke Pafford
1 hour ago
add a comment |
0
active
oldest
votes
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f521633%2fnginx-rewrite-response-in-reverse-proxy-to-point-back-to-initial-location%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f521633%2fnginx-rewrite-response-in-reverse-proxy-to-point-back-to-initial-location%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
I wanted to move this to serverfault, but stackoverflow made it hard to do. oh well
– Luke Pafford
1 hour ago