Question

Web app not working with Caddy

Hi all,

I’ve created a droplet using the 1-click installer with Docker to install a Golang app that starts a server in port 4000 and I’m doing this in my production stage Dockerfile:

EXPOSE 4000
ENTRYPOINT ["./app"] --port 4000

However after running the Dockerfile and making sure the server is running, I want to go to my droplet IP address to make sure it worked, but it just shows the Caddy static website. However, going to the IP:4000 shows my app.

What do I need to do in order to see my web app in the default 80 port? Thanks!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 18, 2024

Hi there,

I believe that you need to configure Caddy to reverse proxy requests from port 80 to your Go app on port 4000.

To do that you have to update your Caddy config file and add a reverse proxy rule, eg:

http://<your-droplet-ip> {
    reverse_proxy 127.0.0.1:4000
}

Just replace the <your-droplet-ip> with your actual Droplet IP address and then restart Caddy:

sudo systemctl restart caddy

After that you should be able to access your web app by navigating to your Droplet’s IP address in the browser without specifying port 4000.

For more information on reverse_proxy config, you can check the documentation here:

https://caddyserver.com/docs/caddyfile/directives/reverse_proxy

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.