Reverse proxy and redirect of http to https site

1. My Caddy version (caddy version):

v2.0.0.0-beta.15 (windows)

2. How I run Caddy:

i will start it with task scheduler to run on system boot but for now just running form command line

a. System environment:

Windows Server 2012 r2

b. Command:

caddy reverse-proxy --from --to localhost:1022

c. Service/unit/compose file:

Binary install not docker

d. My complete Caddyfile or JSON config:

  redir https://{hostonly}{uri}

3. The problem I’m having:

i have a few problems, but this is what i want to do, i have a web application running on the localhost on port 1022.
I want to redirect users the connect to that address to a HTTPS address such as

The localhost is using port 80 so cant bind to it, i have tryed to change the default port 80 to an other port using -http-port but have failed.

I can port forward on the public internet facing firewall port 80 and 443 to any port on the localhost.

4. Error messages and/or full log output:

reverse-proxy: loading new config: http app module: start: tcp: listening on :80
: listen tcp :80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

5. What I already tried:

I have tried verious combinations of putting -http-port 4030 in the caddy file and onthe commandline but to no avale, i think i am missing a basic understanding of how to use Caddy but i cant see it for looking.

6. Links to relevant resources:

Hi @SimonWHIll, welcome to the Caddy community.

Have a look at this for an example:

# Global options (
  # Set the HTTP and HTTPS port manually
  # These options are primarily designed
  # for use cases where public facing
  # ports are forwarded to non-standard
  # ports on the Caddy host.
  http_port 8080
  https_port 8443
} {
  reverse_proxy localhost:1022

That should be all you need.

Forward 80 and 443 on your router to 8080 and 8443 on your Caddy host, then connect to, which should redirect you to, and then proxy to your localhost:1022 service.

1 Like

that is exactly what I wanted, what is the correwct way to get this to run at windows startup?



I don’t think there’s an officially recommended method.

Using the Task Scheduler is probably the simplest way to go, though.

I’m a fan of the Non-Sucking Service Manager myself. (Those guys could use Caddy!)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.