caddy: Caddy proxy redirects to wrong localhost?

I’m trying to translate this simple nginx configuration (taken from the app documentation, see here) into a Caddyfile:

NGINX version:

http {

  map $http_upgrade $connection_upgrade {
      default upgrade;
      ''      close;
    }

  server {
    listen 80;


    location /rstudio/ {
      rewrite ^/rstudio/(.*)$ /$1 break;
      proxy_pass http://localhost:8787;
      proxy_redirect http://localhost:8787/ $scheme://$host/rstudio/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
    }

My Caddyfile:

myserver.com

redir localhost:8787 {scheme}://{host}/rstudio 302
proxy /rstudio localhost:8787 {
  without /rstudio 
}

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?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 20 (5 by maintainers)

Most upvoted comments

I was having this same issue. novaeye’s solutions didn’t help, but using transparent did the trick.

Just in case someone else google’s their way over here.

@cboettig maybe you need add proxy_header Host {host} in proxy section.

Apologies, I misunderstood from last year’s entry that the problem had been fixed by transparent.

Since my application is not proxy-aware, I’ve subscribed to the #1639 rewrite, and await for proxy_redirect #606