TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Switching from Nginx to Caddy

21 点作者 kixpanganiban大约 8 年前

11 条评论

dom0大约 8 年前
&gt; It would be no exaggeration to say that Caddy, an up-and-coming HTTP&#x2F;2 server written in Go that&#x27;s been gaining a lot of traction, is outright witchcraft. Out of the box, it just works. With HTTPS. With very little configuration.<p>It&#x27;s funny that he goes on to compare the two configuration files, where one is a bit verbose, but very clear and easy to understand, while the &quot;Caddyfile&quot; (seriously? xy.conf not good enough anymore?) is four lines that mean basically nothing without a manual.<p>Less configuration is not intrinsically better.
评论 #14032054 未加载
评论 #14031896 未加载
评论 #14032375 未加载
izietto大约 8 年前
What&#x27;s wrong with this?<p><pre><code> server { listen 80; server_name blog.kixpanganiban.com; return 301 https:&#x2F;&#x2F;$server_name$request_uri; } server { listen 443 ssl; server_name blog.kixpanganiban.com; ssl_certificate &#x2F;etc&#x2F;letsencrypt&#x2F;live&#x2F;blog.kixpanganiban.com&#x2F;fullchain.pem; ssl_certificate_key &#x2F;etc&#x2F;letsencrypt&#x2F;live&#x2F;blog.kixpanganiban.com&#x2F;privkey.pem; charset utf-8; # max upload size client_max_body_size 75M; location &#x2F; { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_pass http:&#x2F;&#x2F;localhost:2368&#x2F;; } } </code></pre> Every line is self-explanatory, blocks define clearly where some directive is applied and where not, you just have to read some well-written docs in order to spot the right directive. And this came after Apache configuration mess, when almost nothing did better. Maybe lighttpd, but lighttpd was missing of some essential web server options.
评论 #14032128 未加载
评论 #14032150 未加载
评论 #14033947 未加载
oskarth大约 8 年前
<i>It would be no exaggeration to say that Caddy, an up-and-coming HTTP&#x2F;2 server written in Go that&#x27;s been gaining a lot of traction, is outright witchcraft. Out of the box, it just works. With HTTPS. With very little configuration.</i><p>And the server is down. Irony.
评论 #14031912 未加载
评论 #14035354 未加载
评论 #14031866 未加载
kixpanganiban大约 8 年前
Bleh, this is embarassing. Node in my bottom-tier Lightsail instance is unable to handle the traffic (big surprise) and now I&#x27;m starting a bigger instance from a snapshot.<p>In response to some of the comments:<p>1. I absolutely agree that knowing exactly what something does line by line is much better than &quot;magic&quot;. But that&#x27;s the thing, if you know Caddy as much as you know Nginx, you&#x27;d be able to explain every single one of those 4 lines:<p>&gt; blog.kixpanganiban.com<p>Because I didn&#x27;t bind it specifically to a port (didn&#x27;t add :80 or :443), I know that Caddy will automatically serve it over HTTPS for me and bind it to both. I could have written `blog.kixpanganiban.com:80` instead if I wanted it to be HTTP-only, or even `<a href="http:&#x2F;&#x2F;blog.kixpanganiban.com&#x2F;blog&#x2F;`" rel="nofollow">http:&#x2F;&#x2F;blog.kixpanganiban.com&#x2F;blog&#x2F;`</a> if I wanted to serve it on the `&#x2F;blog` path.<p>&gt; proxy &#x2F; localhost:2386 {<p>Pretty self-explanatory, it proxies all requests to `&#x2F;` to the `localhost:2386` (Ghost) backend. I could attach a list of backends to make it act as a load-balanced reverse proxy similar to nginx, like so: `proxy &#x2F; localhost:2375 somesite.com:2312 {`.<p>&gt; transparent<p>Caddy configs call this a &quot;preset&quot;, basically a shorthand for:<p>header_upstream Host {host}<p>header_upstream X-Real-IP {remote}<p>header_upstream X-Forwarded-For {remote}<p>header_upstream X-Forwarded-Proto {scheme}<p>2. I&#x27;m not trying to sell snake-oil, I&#x27;m trying to introduce a perfectly good alternative which I&#x27;ve been meaning to try for a while. Also, Caddy docs: <a href="https:&#x2F;&#x2F;caddyserver.com&#x2F;docs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;caddyserver.com&#x2F;docs&#x2F;</a>
评论 #14032169 未加载
ComputerGuru大约 8 年前
Site is (currently) down, for what it&#x27;s worth. Someone blogging too early about their&quot;success?&quot;
评论 #14031783 未加载
评论 #14031780 未加载
onion2k大约 8 年前
Looking at the caddy configuration it&#x27;s unclear what it&#x27;s actually doing. From the article &quot;<i>After step 5, Caddy prompted me to enter my email for the LetsEncrypt cert. In the background, it took care of signing me up for LE, verifying my domain ownership, and downloading and attaching my cert files.</i>&quot; That means I can&#x27;t ssh on to a server, cat the http server config file(s), and know what&#x27;s actually happening. That alone is enough for me to not use it.
评论 #14032065 未加载
shocks大约 8 年前
Link is down...<p>Cache: <a href="https:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:MK6zOl_SgQoJ:https:&#x2F;&#x2F;blog.kixpanganiban.com&#x2F;switching-from-nginx-to-caddy&#x2F;+&amp;cd=1&amp;hl=en&amp;ct=clnk&amp;gl=uk" rel="nofollow">https:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:MK6zOl...</a>
sametmax大约 8 年前
Oh, the irony. They website is now down, with an nginx error message.
soulchild37大约 8 年前
502 Bad Gateway From Nginx.... I am perplexed...
评论 #14032114 未加载
macygray大约 8 年前
I&#x27;ve opened a link and got 502 Bad Gateway from ginx&#x2F;1.10.0 (Ubuntu)<p>=) nice
评论 #14032109 未加载
celsoazevedo大约 8 年前
&quot;502 Bad Gateway<p>nginx&#x2F;1.10.0 (Ubuntu)&quot;
评论 #14032055 未加载