Reverse Proxy lost port

1. The problem I’m having:

Hi everyone,
I’m having an issue that I cannot understand whats happening.

I’m trying to setup a reverse proxy in front of an Exchange (owa) .

This is my config (192.168.1.1 is the reverse proxy addres, and 192.168.2.1 is the OWA address)

When I access http://192.168.1.1:10000 The port dissapears from the URL and I can’t continue.

This is product of the Exchange or Caddy ? Maybe something related to http headers ?

Thanks a lot !

2. Error messages and/or full log output:

2024/04/25 15:15:31.014 error   http.log.access.log0    handled request {"request": {"remote_ip": "192.168.4.179", "remote_port": "35214", "client_ip": "192.168.4.179", "proto": "HTTP/1.1", "method": "GET", "host": "192.168.1.1:10000", "uri": "/", "headers": {"Connection": ["keep-alive"], "Upgrade-Insecure-Requests": ["1"], "User-Agent": ["Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"], "Accept-Language": ["en-US,en;q=0.5"], "Accept-Encoding": ["gzip, deflate"], "Dnt": ["1"]}}, "bytes_read": 0, "user_id": "", "duration": 3.024855797, "size": 0, "status": 502, "resp_headers": {"Server": ["Caddy"]}}

2024/04/25 15:15:34.060 error   http.log.access.log0    handled request {"request": {"remote_ip": "192.168.4.179", "remote_port": "35214", "client_ip": "192.168.4.179", "proto": "HTTP/1.1", "method": "GET", "host": "192.168.1.1:10000", "uri": "/favicon.ico", "headers": {"User-Agent": ["Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0"], "Accept": ["image/webp,*/*"], "Accept-Language": ["en-US,en;q=0.5"], "Accept-Encoding": ["gzip, deflate"], "Referer": ["http://192.168.1.1:10000/"], "Dnt": ["1"], "Connection": ["keep-alive"]}}, "bytes_read": 0, "user_id": "", "duration": 3.002424585, "size": 0, "status": 502, "resp_headers": {"Server": ["Caddy"]}}

2024/04/25 15:16:23.444 info    http.log.access.log0    handled request {"request": {"remote_ip": "192.168.4.179", "remote_port": "35216", "client_ip": "192.168.4.179", "proto": "HTTP/1.1", "method": "GET", "host": "192.168.1.1:10000", "uri": "/", "headers": {"User-Agent": ["Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"], "Accept-Language": ["en-US,en;q=0.5"], "Accept-Encoding": ["gzip, deflate"], "Dnt": ["1"], "Connection": ["keep-alive"], "Upgrade-Insecure-Requests": ["1"]}}, "bytes_read": 0, "user_id": "", "duration": 0.00447551, "size": 0, "status": 302, "resp_headers": {"X-Feserver": ["EX2016-MBS"], "Server": ["Caddy", "Microsoft-IIS/10.0"], "X-Requestid": ["34ef725f-9089-4db5-aad5-4456866cd4b7"], "Date": ["Thu, 25 Apr 2024 15:16:23 GMT"], "Content-Length": ["0"], "Cache-Control": ["no-cache"], "Pragma": ["no-cache"], "Location": ["https://192.168.1.1/owa/"]}}

3. Caddy version:

/caddy version
v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

a. System environment:

uname -a
Linux srv 5.10.0-15-amd64 #1 SMP Debian 5.10.120-1 (2022-06-09) x86_64 GNU/Linux

cat /etc/debian_version (its devuan)
11.1

b. Command:

./caddy run

c. Service/unit/compose file:

Don't have. Running on a VM

d. My complete Caddy config:

http://192.168.1.1:10000 {
        log {
                output file caddy.log
        }
        reverse_proxy {
                to https://192.168.2.1:443
                header_up Host Host {http.reverse_proxy.upstream.host}
                transport http {
                        tls
                        tls_insecure_skip_verify
                }
        }
}

5. Links to relevant resources:

I’m so sorry I didn’t realize the template.

You can edit the post to conform to it. People will not help unless you do so

Looks like your webservice sends a redirect to https://192.168.1.1/owa/

As @Forza said, it sounds like your upstream app is serving a redirect. You’ll need to investigate why it tries to redirect.

Seems weird to me that you have Caddy serve HTTP and then you proxy over HTTPS. Typically Caddy is used to terminate TLS, then proxy over HTTP to some unprotected service.

Honestly I didn´t do the test, just was testing caddy and learning.
But thanks for the comment I’m going to try that.