Add official suport to Caddy server #2141

Open
jeanmenezes opened this Issue Sep 6, 2016 · 2 comments

Projects

None yet

2 participants

@jeanmenezes

Technical details

  • YOURLS version: 1.7.1
  • PHP version: 5.6.25
  • OS: Debian Wheezy

Proposal:

I just want to propose official support for the Caddy Server. I have been using YOURLS with Caddy without issue, using the following Caddyfile (mine is located at /etc/caddy/Caddyfile, for instance):

example.com { # could be ip:port, server:port etc., or multiple addresses comma-separated
    root /path/to/yourls
    fastcgi / /var/run/php5-fpm.sock php # it can vary
    rewrite / {
        r (.*)
        to {uri} {uri}/ /yourls-loader.php?{query}
    }
}

Also, if you want to serve YOURLS on multiple hosts/ports, you can do it and use nginx for load balancing. The following Caddyfile would do the first part of the trick:

host:port1, host:port2, host2:portN, hostN:portN {
    root /path/to/yourls
    fastcgi / /var/run/php5-fpm.sock php # it can vary
    rewrite / {
        r (.*)
        to {uri} {uri}/ /yourls-loader.php?{query}
    }
}

and then you should config nginx to function accordingly:

http {
    ...
    upstream upstreamname {
        server host:port1;
        server host:port2;
        server host2:portN;
        server hostN:portN;
    }

    server {
        listen 80;
        server_name your.yourls.url;
        location / {
            proxy_pass http://upstreamname;
            # important to avoid 404 errors from caddy:
            proxy_set_header Host your.yourls.url;
        }
    ...
}

One should remember, though, that caddy can run either locally from the current directory, if ./Caddyfile is present (that is, single site), as well as globally, fetching configs from /etc/caddy/Caddyfile (good for multiple sites under the same host).

I think it would be nice to have all this info in the wiki, as caddy has a growing number of users, who normally run into issues on more complex use cases.

@ozh
Member
ozh commented Sep 6, 2016

Interesting, thanks for sharing!

I don't think we're going to support this "officially" because we have no in-house users and would be unable to assist people troubleshooting things.

Ideally, * you * would support this :) Maybe via a post on a permanent site (ie not a blog that may vanish in 12 months) or even simply via a Github repo with just a readme to explain, where people could share via issues different configs or comments.

@jeanmenezes

Right, I understand the "official/unofficial" support issue. I'm going to figure out some way to publicize this config (caddy forums/wiki maybe?) and let you know.
However, this very topic here will appear as a reference in search engines, so that is a reasonable start :)

Thanks for your attention and keep the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment