Reverse proxy config for TT-RSS


(Jean-Philippe Baril) #1

Hi,

I’m trying to configure Caddy to serve as reverse to Tiny Tiny RSS (https://tt-rss.org) running in a Docker container. It kind a work, but it still has an annoying behaviour.

I currently have:

domain.com {
  root /srv
  
  redir /tt-rss /tt-rss/
  proxy /tt-rss/ ttrss-container {
    without /tt-rss
    transparent
  }
}

I can access it at domain.com/tt-rss, but after I login instead of being redirected to domain.com/tt-rss/index.php I’m redirected to domain.com/index.php. It’s not that of a problem because if I go again to domain.com/tt-rss/ it then work as expected. So it’s just the redirection after login that does not work correctly.

I searched the app code (https://git.tt-rss.org/git/tt-rss/src/master/include/sanity_check.php#L17) and it seems it is because php variables $_SERVER[“HTTP_HOST”] and $_SERVER[“REQUEST_URI”] don’t contain the ‘tt-rss’ part. I suppose it has to do with the ‘without /tt-rss’ part in Caddyfile.

A nginx example I found that supposedly work:

location /tt-rss/ {
    index index.php;
    rewrite /tt-rss(.*) /$1 break;
    proxy_pass http://localhost:8000;
}

I also found this other nginx config on another forum:

location /ttrss/        {
            proxy_pass http://192.168.20.17/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

I seem to understand that the ‘transparent’ directive is an alias for the directives in the later example.
Would I need to do a rewrite directive as in the first example?

I searched the doc and forums but as I don’t know much of webservers and reverse proxy I’m really lost here.

Is there anything I could do to solve that?

Thanks a lot.


(Matthew Fay) #2

The problem is that the app, inside Docker, thinks that it’s being served from the site root (i.e. /). It’s not, though - you’re serving it from a sub-folder.

You’ve got three options, really;

  1. Tell the app, somehow, that it is being served from a sub-folder so it knows to prepend its links correctly.
    This might not be possible if the app isn’t programmed to do this. You can search the app’s settings for somewhere to set this manually, or you can exclude without /tt-rss from your Caddyfile and test to see if the app is programmed to automatically pick up on it.
  2. Use http.filter to search for links coming back from your app and modify them appropriately before sending it back to the client.
  3. Serve your app from a subdomain instead of a sub-folder.

(Jean-Philippe Baril) #3

If I exclude without /tt-rss from my Caddyfile it does not work.
I’ll maybe have to use a subdomain.

Thanks for your answer.