Why I am unable to create multiple http server with multiple ports in a single CaddyFile with command systemctl in CentOS 7?

1. My Caddy version (caddy -version):

v1.0.3

2. How I run Caddy:

[failed]
systemctl start caddy

[successed]
/usr/bin/caddy -conf /etc/caddy/caddy.conf -root /tmp -agree

a. System environment:

CentOS 7

b. Command:

Only vim /etc/caddy/caddy.conf
and systemctl start caddy

c. Service/unit/compose file:

I didn’t edit or set anything, all is new with yum install -y caddy

d. My complete Caddyfile:

:8080 :8081 {
  root /www
}

#label_2 {
#  localhost:8702
#}
# import conf.d/*.conf

3. The problem I’m having:

I can’t successfully run caddy with systemctl but pure caddy command is OK.

4. Error messages and/or full log output:

/etc/caddy:$ systemctl start caddy
/etc/caddy:$ systemctl status caddy
● caddy.service - Caddy HTTP/2 web server
Loaded: loaded (/usr/lib/systemd/system/caddy.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2019-11-14 15:57:16 PST; 6s ago
Docs: Welcome — Caddy Documentation
Process: 23555 ExecStart=/usr/bin/caddy -conf /etc/caddy/caddy.conf -root /tmp -agree (code=exited, status=1/FAILURE)
Process: 23542 ExecStartPre=/usr/bin/caddy -conf /etc/caddy/caddy.conf -validate (code=exited, status=0/SUCCESS)
Main PID: 23555 (code=exited, status=1/FAILURE)

Nov 14 15:57:15 localhost.localdomain systemd[1]: Starting Caddy HTTP/2 web server…
Nov 14 15:57:16 localhost.localdomain systemd[1]: Started Caddy HTTP/2 web server.
Nov 14 15:57:16 localhost.localdomain caddy[23555]: Activating privacy features… done.
Nov 14 15:57:16 localhost.localdomain systemd[1]: caddy.service: main process exited, code=exited, status=1/FAILURE
Nov 14 15:57:16 localhost.localdomain systemd[1]: Unit caddy.service entered failed state.
Nov 14 15:57:16 localhost.localdomain systemd[1]: caddy.service failed.

5. What I already tried:

And here is one thing I think I should mention, in some early tests I get a warning output from pure command /usr/bin/caddy -conf /etc/caddy/caddy.conf -root /tmp -agree called 'WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with ulimi│tcp 0 0 0.0.0.0:44782 0.0.0.0:* LISTEN 2283/ss-server t -n 8192. ’ (maybe the port I’ve change the ports later, but in all there are 2 ports in my CaddyFIle from the begining to th end).

And in /usr/bin/caddy command it just gave me a warning, but run successfully.
But if I use systemctl start caddy, it gave no response and finished to my shell, and when I again typed in systemctl status caddy, it printed the error message above.

I used command ulimit -n 8192 to solve the warning, and I have thought everything should be OK with systemctl, but it doesn’t.

cat you cat your systemd config file? and show that,
ulimit is not NEEDED, but is highly reccomended

I can see in your ExecStart command there is no process log output.

If you edit your unit file to add the -log stdout flag to your ExecStart, then run it again, we might get some more info as to why Caddy might be failing out.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.