caddyserver / forwardproxy

Forward proxy plugin for the Caddy web server
Apache License 2.0
582 stars 218 forks source link

Caddy2 support not only 443 port #87

Closed snadn closed 2 years ago

snadn commented 2 years ago

why v2 only support 443 port? can support other port?

In the Caddyfile the addresses must start with :443 for the forward_proxy to work for proxy requests of all origins.

https://github.com/caddyserver/forwardproxy/blob/caddy2/README.md?plain=1#L19

mholt commented 2 years ago

Because 443 is the HTTPS port, so pretty much every site you visit with HTTPS will be on port 443; and I think that's also due to limitations in the proxy clients and their configuration possibilities.

snadn commented 2 years ago

@mholt Maybe it will be more flexible to make the port configurable. Sometimes we may expect to provide https service through other ports

mholt commented 2 years ago

I don't think that will do any good unless proxy clients support that.

snadn commented 2 years ago

@mholt The proxy client supports custom ports, such as SwitchyOmega. I used port 8443 when I used Caddy v1. image

mholt commented 2 years ago

Ah, so I think I misread/misunderstood originally.

I don't think the port number itself is the point of that sentence. It's saying that your site address can't be example.com or example.com:443 because Caddy will need to be configured to respond to requests with any Host header, not just your own domain name. So the port number can be :8443 or anything else (if clients support it), but you want to omit the domain name.

snadn commented 2 years ago

@mholt I think that when Caddy acts as an https proxy, the domain in the configuration is necessary, and the port can be set arbitrarily. The desired configuration is as follows:

https://example.com:xxxx {
  forward_proxy {
    ...
  }
}

The proxy configuration takes effect only when accessing the domain name specified in the configuration. The configuration of Caddy v1 can meet expectations, but v2 cannot.V2 can take effect with any configured domain name access.