-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caddy proxy redirects to wrong localhost? #444
Comments
Are you getting redirected to |
I'm getting redirected to |
If it helps to debug, the app is dockerized, so this behavior should be relatively straight-forward to reproduce if you have docker installed. e.g. just run: |
Alright. Got my hands tied right now but hopefully before end of the day (if someone else hasn't come around). |
This line is what is causing your redirect:
But this line in nginx conf causes a rewrite:
So, you want a rewrite, which changes the URL internally but doesn't issue a response. Basically this rewrite just strips rstudio from the URL. |
Actually j/k, just get rid of the |
@mholt thanks, I really appreciate your help in debugging this. I tried dropping the redir but no luck, that still forwards me to the Right, like you say, my reading was that the I also tried using the Caddy rewrite instead of
That doesn't go to I tried testing without the need for any
in the Caddyfile. And that sends me to So I'm stuck. In the nginx, I see the rewrite and redir clauses are placed within the |
I'm not convinced Caddy is redirecting without that |
@mholt hmm, tried all that, still persists. I've cleared the browser cache & all associated history, and have also tried switching to another domain name to avoid any caching that might exist between my computer and the server. I've reset the app. No luck. It seems like the app itself is responsible for returning its |
@cboettig maybe you need add |
^ That's possible. Strange that the app insists on forwarding like that. You can confirm this by looking at the Network tab of your browser's inspector tools - even a screenshot or two of the requests and the response headers might be useful. But try @novaeye's suggestion and see what happens. |
@novaeye Thanks, that pretty much does it! With one problem. When hosting from root, all I need is this:
Hosting from the
and it almost works, except that I need to go to This appears to be because the app loads a page looking for javascript at |
This hack could work
|
@abiosoft Thanks, that works for me. Incidentally, Caddy won't let me write a |
Thanks everyone for all the help, much appreciated and happy to have this all working nicely now! |
Its my mistake. :) Glad it worked in the end. |
I was having this same issue. novaeye's solutions didn't help, but using Just in case someone else google's their way over here. |
My Caddyfile is:
It should reverse-proxy an upstream http://www.ac.upt.ro/forum/ to a new Caddy-served downstream https://forum.ac.upt.ro/ I’ve setup a minimal <?php
if (isset($_GET['getnews']))
{
header("HTTP/1.1 302 Moved Temporarily");
header("Location: http://www.ac.upt.ro/forum/index.php?showtopic=2711&pid=149620&st=0&#entry149620");
exit;
}
if (isset($_GET['showtopic']))
{
exit("here's what's new..");
}
exit("try <a href='./?getnews'>?getnews</a> or <a href='./?showtopic'>?showtopic</a>");
?> https://forum.ac.upt.ro/?showtopic works as expected. But https://forum.ac.upt.ro/?getnews just serves directly the upstream reply from http://www.ac.upt.ro/forum/?getnews which has a hostnamed 302-redirect to http://www.ac.upt.ro/forum/index.php?showtopic=2711&pid=149620&st=0&#entry149620 I’d have expected the reply to be a transparent https://forum.ac.upt.ro/index.php?showtopic=2711&pid=149620&st=0&#entry149620 I can’t even find a workaround, something like a non-existing |
@uptad0112 Caddy doesn't rewrite Location headers, if that's what you're asking for -- the application needs to redirect properly, i.e. it has to know it's behind a reverse proxy (this is true of most applications). For further discussion, try asking on our forum, rather than 3-year-old closed issue: https://caddy.community |
I'm trying to translate this simple nginx configuration (taken from the app documentation, see here) into a Caddyfile:
NGINX version:
My Caddyfile:
But this Caddyfile, rather than proxy-ing in to the application running on localhost of port 8787, literally redirects my browser to point to it's own localhost. Not sure where I've gone wrong; the nginx is a bit opaque to me (though it works just fine). Any suggestions?
The text was updated successfully, but these errors were encountered: