Server static html and wordpress to a domain name

Caddy version: 0.9.5
uname -a : Linux portfolio 4.8.0-46-generic #49-Ubuntu SMP Fri Mar 31 13:57:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
php: 7.0.15


I wanted to server host static html at / and a wordpress site at /fm with my domain name.
I have set up both dns and domain and vultr and namecheap and they work with nginx.

I have tried various Caddyfile configuration such as

and ran it with caddy -conf="Caddyfile"

Firefox won’t load the static site at /. Request header is

GET / HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
DNT: 1
Upgrade-Insecure-Requests: 1
Connection: keep-alive

…with no response.

I tried with curl and I got

$ curl
<a href="">Moved Permanently</a>.

I tried adding logs {
        root /var/www/html
        log ../access.log
        errors ../errors.log

and got

Activating privacy features... done.
WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with "ulimit -n 8192".

I tried to open it with firefox, nothing happens. Curl output is the same as before. 0 bytes in both access.log and errors.log

Setting setcap cap_net_bind_service=+ep /usr/local/bin/caddy does not change anything too.

I am trying to get the static site at / to work fist before adding fastcgi /fm /var/run/php/php7.0-fpm.sock php to get the wordpress site working. Any idea why it gives 301 error?


Hold on, tried curl -v and I got port 80: Connection refused.

$ curl -v
* Rebuilt URL to:
*   Trying xx.xx.xx.xx...
* connect to xx.xx.xx.xx port 80 failed: Connection refused
* Failed to connect to port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to port 80: Connection refused

So I and changed the Caddyfile to {
        root /var/www/html
        log ../access.log
        errors ../errors.log
... but won't connect.

Hey Hafiz, welcome.

The 301 isn’t an error, that’s a redirect to the secure site (https) as expected. Caddy seems to be working properly there.

When you try the request again with -v and it gives you “connection refused” means that something is wrong with your system or network configuration; obviously caddy is running or it wouldn’t have given the 301.

But if the logs are empty, it’s either because they haven’t flushed to disk yet (try stopping caddy with SIGINT or sending lots of requests) or your requests aren’t actually going to Caddy like you think they are.

Make absolutely sure your network/system environment is configured properly, and first resolve the weird inconsistencies with your curl commands; either caddy is responding or it is not (and it does once it has started). If it’s running but your client can’t connect, then there’s something in the middle that’s stopping the connection.

Turns out it is a firewall problem. Ufw disallows any https connection.

I fixed it with
sudo ufw allow 'Nginx Full'
and then
sudo ufw delete allow 'Nginx HTTP'

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