Apache behind Caddy reverse proxy

So I am using a web app when users can connect their custom domain to their profiles.
My configuration majorly includes Apache, PHP and MySQL

So I changed my default port 80 to 8080 - this is my apache port file

If you just change the port or add more ports here, you will likely also

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 8080

# <IfModule ssl_module>
# 	Listen 443
# </IfModule>

# <IfModule mod_gnutls.c>
# 	Listen 443
# </IfModule>

Installed caddy on my server and edited my caddy file to use my domain name

{
    email myemail
    acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}

mydomain {

  reverse_proxy / localhost:8080 
  
}

Correct me if I need to add something in caddy file, Im pretty new to caddy server. Also am I point it correctly to my apache port?
Config.json:

{
  "apps": {
    "tls": {
      "automation": {
        "policies": [
          {
            "issuer": {
              "module": "acme",
              "email": "myemail"
            },
            "on_demand": true
          }
        ],
        "on_demand": {
          "rate_limit": {
            "interval": "5m",
            "burst": 100
          }
        }
      }
    },
    "http": {
      "http_port": 80,
      "https_port": 443,
      "servers": {
        "tiendas": {
          "listen": [":80", ":443"],
          "max_header_bytes": 41943040,
          "routes": [
            {
              "handle": [
                {
                  "handler": "reverse_proxy",
                  "upstreams": [
                    {
                      "dial": "localhost:8080"
                    }
                  ]
                }
              ],
              "terminal": true
            }
          ]
        }
      }
    }
  }
}

For now I did not use “ask” directive as I dont exactly know what url to pass in and how it performs!

So this has been my configuration so far as Apache behind caddy reverse proxy, but when I visit my main domain I only the plain html is loaded and css/js are not loaded.
Also my other pages are not accessible, only main domain. And when I map my other domain(users custom domain), it doesn’t load.

Can someone please help, I can really use some help!!

Why do you have / in this line:

reverse_proxy / localhost:8080 

I am not sure that is your intent, but I could be wrong. Read about how request matchers work here: Request matchers (Caddyfile) — Caddy Documentation - that should answer the question!

1 Like

It worked, thankyou!!

But I still cannot generate ssl for my custom domain pointing to my server with cname do not load “This site can’t provide a secure connection”
Error:

"http","msg":"user server is listening on same interface as automatic HTTP->HTTPS redirects; user-configured routes might override these settings"
"http","msg":"enabling automatic TLS certificate management","domains":["maindomain.com"]}

All errors are same as this one.
I think this is something to do with tls on demand and ask directive, can someone please help me figure out this issue!

I would really appreciate your reply!!

This topic was automatically closed after 30 days. New replies are no longer allowed.