I am using docker but there is no compose file, it works in a different way
What I have is a web *service* (not web server serving html content) that receives API requests
d. My complete Caddyfile or JSON config:
not installed yet, I'm searching for a solution
3. The problem I’m having:
4. Error messages and/or full log output:
5. What I already tried:
6. Links to relevant resources:
A friend is helping me achieve this and told me to come to this forum for further help
I have a ubuntu 20.04 virtual private server running a docker app that is listening on port 4001
When I access the public IP of that server on port :4001 I am able to reach my service no problem
Now I need to have https enabled for that docker app since this server is used by a frontend app hosted in another server (vercel)
Really all I need to do is find a way to make the requests to port 4001 over https to reach that app that is running on localhost:4001
I have read a few tutorials and posts and they all mention to use the default 443 https port and thats not my case
Also they all have instructions to serve files from a root/www folder which again is not my case
Could someone suggest me a simple way to achieve that
The docker container runs an app which I cannot change in any way, its a node for a blockchain and when it starts it opens on the local machine the address localhost:4001, does not matter if you are sending requests over http or https.
The frontend app is delivered over https, and when it tries do send requests from https to http the browser does not allow, that is why I need to receive https requests on that server, but I can chance the frontend to connect to another port, or to not specify the port and let to go to default, as long as the app can still receive those requests on port 4001
There is no problem for me to reroute requests on the server at port 443 to the port 4001, specially if this is easier to setup, my frontend can connect to any port on https
The port that your upstream app uses doesn’t matter, 4001 is fine.
What matters is the port Caddy listens on for incoming requests. Ports 80 and 443 are the default HTTP and HTTPS ports by default, and ACME issuers require those ports to be used when using the ACME HTTP or TLS-ALPN challenges (the DNS challenge doesn’t have a port requirement though).
Caddy’s reverse_proxy is what will send the request to your upstream app over port 4001, then stream the response back to the client afterwards.
I have a domain for example xyz.duckdns.org
I wonder if the caddy config file seems correct for my usecase
This seems too simple, am I missing something?
All the other attributes from the other config files I read on the forums and on the docs mention things I don’t need, generally all related to serving files.
Nope, that’s about it. That’ll enable Automatic HTTPS for that domain (manage TLS certificates for that domain – as long as your DNS points to the right IP address, and server is publicly reachable on ports 80 and 443) then proxy any request received to your upstream app.