Monviech / os-caddy-plugin

Caddy Plugin with GUI for OPNsense
Other
38 stars 0 forks source link

Set CA certificate on handles so HTTPS can be used with Backend Servers #49

Closed Monviech closed 8 months ago

Monviech commented 8 months ago

There has to be an option to set a certificate on handles, since Caddy doesn't allow "ignore certificate checks" anymore. If the backend server has a self signed certificate, that certificate has to be imported into the OPNsense Trust store, and then be able to be selected in the handle.

Right now this is possible (SSL Termination): Internet <--HTTPS--> Caddy <--HTTP--> Backend Server

But this isn't possible: Internet <--HTTPS--> Caddy <--HTTPS--> Backend Server

Example:

# Example Domain with Backend HTTPS:

foo.bar.example.com {
        handle {
                reverse_proxy 192.168.1.1 {
                        transport http {
                                tls
                                tls_trusted_ca_certs /usr/local/etc/caddy/certificates/temp/32423423.pem
                        }
                }
        }
}

## Example Subdomain with Backend HTTPS:

*.example.com:443 {
        tls {
                dns cloudflare 1484053787dJQB8vP1q0yc5ZEBnH6JGS4d3mBmvIeMrnnxFi3WtJdF
        }

        handle {
                reverse_proxy 192.168.1.1:443 {
                        transport http {
                                tls
                                tls_trusted_ca_certs /usr/local/etc/caddy/certificates/temp/32423423.pem
                                }
                        }
                }
        }
        @4c087454-ee7e-462d-a603-e58eee82a2b7 host foo.example.com
        handle @4c087454-ee7e-462d-a603-e58eee82a2b7 {
                handle /owa/* {
                        reverse_proxy 192.168.1.1:8443 {
                                transport http {
                                tls
                                tls_trusted_ca_certs /usr/local/etc/caddy/certificates/temp/32423423.pem
                                }
                        }
                }
                handle {
                        reverse_proxy 192.168.1.1:443 {
                                transport http {
                                tls
                                tls_trusted_ca_certs /usr/local/etc/caddy/certificates/temp/32423423.pem
                                }
                        }
                }
        }
}

Originally posted by @Monviech in https://github.com/Monviech/os-caddy-plugin/issues/36#issuecomment-1860190723

Monviech commented 8 months ago

https://github.com/Monviech/os-caddy-plugin/pull/51