Need help with my roundcube proxy server block

Discussion in 'Server Operation' started by Heeter, Nov 22, 2025.

  1. Heeter

    Heeter Member HowtoForge Supporter

    I have a mature working postfix/dovecot with roundcube running on a dedicated Ubuntu22LTS server: 192.168.3.18

    I also have a webserver with nginx/let'sencrypt on a dedicated Ubuntu22LTS server: 192.168.3.19

    I don't have any errors when I type "192.168.3.18" into the browser, roundcube comes up

    I keep getting too many redirect errors with the proxy file "mail.conf" that I created in /etc/nginx/conf.d/:

    Code:
    server {
     listen 443;
     server_name mail.example.com;
    
     proxy_hide_header X-Powered-By;
     add_header X-Xss-Protection "1; mode=block" always;
     add_header X-Content-Type-Options "nosniff" always;
     add_header Strict-Transport-Security "max-age=2592000; includeSubdomains" always;
     add_header X-Frame-Options "SAMEORIGIN" always;
     add_header 'Referrer-Policy' 'no-referrer';
    
     add_header Content-Security-Policy "frame-ancestors example.com mail.example.com";
    
     location / {
     proxy_pass http://192.168.3.18:80;
    
     proxy_hide_header X-Powered-By;
     proxy_set_header Range $http_range;
     proxy_set_header If-Range $http_if_range;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header Host $host;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";
     }
     ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
     ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    }
    
    I do have other working proxy servers working out of that folder

    Would anyone be able to assist me with this file? Or am I going about it incorrectly?

    Regards
     
  2. remkoh

    remkoh Active Member HowtoForge Supporter

    Those should be logged in the access log by at least one of the webservers.
    You should find repeating GET lines where the uri will be longer (something will be added repetitively) each line.
    Question is if it is the roundcube server or proxy server causing it.
     
    Last edited: Nov 23, 2025
  3. Heeter

    Heeter Member HowtoForge Supporter

    Hi Thank you for the idea

    Just checked, it is showing up on the roundcube server nginx access log
    Any ideas?
     
  4. remkoh

    remkoh Active Member HowtoForge Supporter

    What is the log showing you?

    I'm doing something similar, proxying to roundcube on a ispconfig node but leaving out the roundcube folder in the browser's address bar.
    Code:
    ...
    location = / {
        rewrite ^ /roundcube/ last;
    }
    
    location / {
        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_set_header Host $host;
        proxy_http_version 1.1;
        proxy_intercept_errors on;
        proxy_pass https://<mailserver>/roundcube/;
        proxy_redirect https://<mailserver>/roundcube/ /;
        sub_filter_once off;
        sub_filter '/roundcube/' '/';
    }
    ...
    
    Eventhough I'm proxying within the same server, that should make no difference.
     
  5. Heeter

    Heeter Member HowtoForge Supporter

    Hi remkoh

    Thank you for your assistance,

    After editing the mail.conf on the proxy server to reflect your location block, still getting too many redirect errors on the roundcube server.

    Code:
    192.168.3.19 - - [24/Nov/2025:01:21:49 +0000] "GET /mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail:80/mail HTTP/1.1" 301 162 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36"
    
    I tried a whole new server conf file in the sites-enabled folder side ofthe proxy server instead, same results.

    Looks like it the roundcube server has something that is being triggered?

    Regards
     
  6. remkoh

    remkoh Active Member HowtoForge Supporter

    And when you put a trailing slash behind the proxy_pass url?

    So
    Code:
    proxy_pass http://192.168.3.18:80;
    becomes
    Code:
    proxy_pass http://192.168.3.18:80/;
    And where did "mail" come from?
    It doesn't show anywhere in your opening post.
    If it is a folder then you have put the portnumber in the wrong place.
    Portnumber always is behind the server address and before the uri.
     
    Last edited: Nov 24, 2025
  7. Heeter

    Heeter Member HowtoForge Supporter

    Hi remkoh

    I want to thank you for staying with me on this one.

    the mail folder defaults to when I enter into the browser:
    Code:
    http://192.168.3.18
    
    it becomes:
    Code:
    http://192.168.3.18/mail/
    
    I have been trying:
    Code:
    proxy_pass http://192.168.3.18:80/;
    proxy_pass http://192.168.3.18/mail:80/;
    proxy_pass http://192.168.3.18/;
    proxy_pass http://192.168.3.18/mail/;
    
    Always same too many redirect errors

    I paid for a howtoforge forum supporter last night, I think that I will setup an ISPConfig server. Haven't tried ISPConfig since late 2000s
     
  8. remkoh

    remkoh Active Member HowtoForge Supporter

    If roundcube runs under the mail folder you can copy paste my config and replace roundcube with mail.
    That way you should be able to run roundcube in your browser with "mail.example.com" only in the browser's addressbar.

    I've had a similar problem as you are having and I think the last 2 or 3 lines of the "location /" directive and the "location = /" directive together where my solution.

    So for you it would become
    Code:
    location = / {
       rewrite ^ /mail/ last;
    }
    
    location / {
       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_set_header Host $host;
       proxy_http_version 1.1;
       proxy_intercept_errors on;
       proxy_pass http://192.168.3.18:80/mail/;
       proxy_redirect http://192.168.3.18:80/mail/ /;
       sub_filter_once off;
       sub_filter '/mail/' '/';
    }
    
    You should be able to add most of your extra header lines.
     
  9. Heeter

    Heeter Member HowtoForge Supporter

    Hi remkoh

    Code:
    192.168.2.21 - - [25/Nov/2025:01:59:46 +0000] "GET /mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail/mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mail:443mailHTTP/1.1" 301 162 "-" "Mozilla/
    5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36"
    
    Thank you for your input.
    Still getting redirects, but they are different now?
     
  10. Heeter

    Heeter Member HowtoForge Supporter

    Actually, I am going to go in a different direction, remkoh.
    Just completed installing the whole ispconfig main server and all slave servers. Going to go in that direction.
    Thank you for all your assistance
     
  11. remkoh

    remkoh Active Member HowtoForge Supporter

    That's what I'm running too, dedicated nodes voor web (apache and nginx), db (mariadb galera cluster), mail (including webmail on nginx), dns (primary and slave, not mirrored!) and panel.
    Dns nodes also run a haproxy cluster in front of the web and panel nodes.
     
    ahrasis and till like this.

Share This Page