Please help a noob set up an ubuntu web server [solved]

so I have been banging my head against my desk for the last 3 hours trying to get this working. so I have been trying to follow a digital ocean guide to setting up an ubuntu web server using a tool called caddy. the link to this tutorial is here "https://www.digitalocean.com/community/tutorials/how-to-host-a-website-with-caddy-on-ubuntu-16-04" so, I got all the way up to the second to the last step of typing the IP Address in to chrome and going to the test page that I set up in a previous step, but it is saying that the server is refusing to connect. While I have been using Ubuntu for a few years now on my home machine this is the first time that I have used it for hosting a website. can anyone help me out here by either helping me fix caddy, or suggesting another tool that would make this work? thank you.

Ping your server and see if you get a response.

Try step 4 again as it seems your server is blocking that port.

the ping connected, and 0 packets lost. running "sudo ufw status" returned

Status: active

To Action From


80 ALLOW Anywhere
443 ALLOW Anywhere
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
21/tcp ALLOW Anywhere
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
21/tcp (v6) ALLOW Anywhere (v6)

sudo systemctl status caddy

what does that return?

I think that we have something!

● caddy.service - Caddy HTTP/2 web server
Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Thu 2017-07-06 22:28:29 UTC; 4h 49min ago
Docs: https://caddyserver.com/docs
Process: 1531 ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp (code=exited, status=1/FAILURE)
Main PID: 1531 (code=exited, status=1/FAILURE)

Jul 06 22:28:29 ubuntu-512mb-nyc3-01 systemd[1]: caddy.service: Service hold-off time over, scheduling restart.
Jul 06 22:28:29 ubuntu-512mb-nyc3-01 systemd[1]: Stopped Caddy HTTP/2 web server.
Jul 06 22:28:29 ubuntu-512mb-nyc3-01 systemd[1]: caddy.service: Start request repeated too quickly.
Jul 06 22:28:29 ubuntu-512mb-nyc3-01 systemd[1]: Failed to start Caddy HTTP/2 web server.
Jul 07 02:19:47 ubuntu-512mb-nyc3-01 systemd[1]: caddy.service: Start request repeated too quickly.
Jul 07 02:19:47 ubuntu-512mb-nyc3-01 systemd[1]: Failed to start Caddy HTTP/2 web server.
Jul 07 02:21:45 ubuntu-512mb-nyc3-01 systemd[1]: caddy.service: Start request repeated too quickly.
Jul 07 02:21:45 ubuntu-512mb-nyc3-01 systemd[1]: Failed to start Caddy HTTP/2 web server.
Jul 07 02:27:56 ubuntu-512mb-nyc3-01 systemd[1]: caddy.service: Start request repeated too quickly.
Jul 07 02:27:56 ubuntu-512mb-nyc3-01 systemd[1]: Failed to start Caddy HTTP/2 web server.

Dude hit your logs:

What happens in your error.log, secure.log, access.log

Review them first and then do tail -f *.log in the apache log dir in a terminal and then visit the page ina browser. See what happens.

I think they're in /var/log/apache2/ on Ubuntu but I'm not 100% certain because I use a server OS that places them in the proper /var/log/httpd/ directory (Jk)

Also try to curl your page and see what exit code it returns.

Sesriously though... post those logs!!!

I think you can do journalctl -xe for more info on system d failures.

By the way - you're mileage is going to vary on my previous post. I thought you had apache going. Still try to find the caddy logs and tail them while you visit the page.

this is what I've pulled from the log.

Jul 07 03:53:44 ubuntu-512mb-nyc3-01 systemd[1]: caddy.service: Start request repeated too quickly.
Jul 07 03:53:44 ubuntu-512mb-nyc3-01 systemd[1]: Failed to start Caddy HTTP/2 web server.
-- Subject: Unit caddy.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit caddy.service has failed.
--
-- The result is failed.
Jul 07 03:53:44 ubuntu-512mb-nyc3-01 systemd[1]: Network Service is not active.
Jul 07 03:53:44 ubuntu-512mb-nyc3-01 systemd[1]: Dependency failed for Wait for Network to be Configured.
-- Subject: Unit systemd-networkd-wait-online.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-networkd-wait-online.service has failed.
--
-- The result is dependency.
Jul 07 03:53:44 ubuntu-512mb-nyc3-01 systemd[1]: systemd-networkd-wait-online.service: Job systemd-networkd-wait-online.service/start failed with result 'dependency'.
Jul 07 03:53:44 ubuntu-512mb-nyc3-01 sudo[2182]: pam_unix(sudo:session): session closed for user root
Jul 07 03:54:02 ubuntu-512mb-nyc3-01 sudo[2213]: fizzyquizzler : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/journalctl -xe
Jul 07 03:54:02 ubuntu-512mb-nyc3-01 sudo[2213]: pam_unix(sudo:session): session opened for user root by fizzyquizzler(uid=0)

He's on Fedora but see if that helps

NVM. catching up on what you said, ill edit this as necessary.

Totally stolen from stack but check out that second guys answer

See what happens if you comment out that restart=on-failure,
Restart that bad boy and when it fails hit it with journalctl -u caddy to see if there's an underlying problem.

journalctl -f -u caddy.service

What does that return?

this worked! the web server is excepting connections!

1 Like

thank you both @cotton and @Novasty for your help. you guys rock!

Nice job! Congrats on getting my your server up - I deem you sysadmin worthy and bestow hereforth all responsibility that entails.

With that said - please for the sake of a lot of on this forum: monitor port 22, keep your server patched, and don't lose root on your box.

There are a lot of people who spin up severs, fail to do anything I mentioned and then people like me get their day ****ed up (and there's a lot of others on this site too in the same boat) because someone spun up a server, got bored of it, left it online unpatched and unmonitored. Some jagoff cracks root on 22, puts up a phishing site and now I have a fire put out and another damn zombie site I have to shut down.

So please, please, please take care of your server. You're a steward of the net now. If you ever get bored of it or lose root, please call the host and get it taken offline.

Rock on!

1 Like

If you need me to pentest your site, let me know :stuck_out_tongue_winking_eye:

1 Like

I can hear my custom tails (with the pentest tools installed) linux environment USB vibrating in my pocket.. itching on that comment :stuck_out_tongue: haha

thanks for the advice, yeah this site if for the small Game studio that I am trying to start with some friends, so me loosing interest in it is unlikely for now. but Ill make sure to keep it patched up as often as possible.

Yeah, I'm new to the whole server admin thing. been on linux for about 2 years now, but desktop is a whole other beast. if anyone has any recommendations for books or youtube channels that I can binge on to help me catch up a little that would be super.

Ill keep that in mind thanks, I'm just trying to get the thing up and running now.