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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Nginx for Developers: An Introduction

434 点作者 jenius将近 12 年前

26 条评论

sergiotapia将近 12 年前
If you like this article, I wrote a similar one called Devops for Dummies.<p><a href="http:&#x2F;&#x2F;tech.pro&#x2F;tutorial&#x2F;1335&#x2F;devops-for-dummies-vps-configuration-from-scratch-rails-nginx-postgresql" rel="nofollow">http:&#x2F;&#x2F;tech.pro&#x2F;tutorial&#x2F;1335&#x2F;devops-for-dummies-vps-configu...</a><p>It teaches you how to setup a DigitalOcean (or any other) VPS from scratch to host N amount of Rails applications using Nginx and Passenger. It took me some time to get things working properly and I distilled it into this short article that holds your hand and takes you from A to Z.
评论 #5907719 未加载
评论 #5908056 未加载
评论 #5908680 未加载
评论 #5909604 未加载
评论 #5911088 未加载
评论 #5907939 未加载
评论 #5909624 未加载
评论 #5907468 未加载
评论 #5907003 未加载
TallboyOne将近 12 年前
Good article. Be wary of the well documented zero-day exploits if you&#x27;re using php.<p>This is one of my other favorite articles: <a href="http:&#x2F;&#x2F;docs.ngx.cc&#x2F;en&#x2F;latest&#x2F;topics&#x2F;tutorials&#x2F;config_pitfalls.html" rel="nofollow">http:&#x2F;&#x2F;docs.ngx.cc&#x2F;en&#x2F;latest&#x2F;topics&#x2F;tutorials&#x2F;config_pitfall...</a><p>Some good introductory stuff here as well: <a href="http:&#x2F;&#x2F;pineapple.io&#x2F;resources&#x2F;tagged&#x2F;nginx" rel="nofollow">http:&#x2F;&#x2F;pineapple.io&#x2F;resources&#x2F;tagged&#x2F;nginx</a>
评论 #5906953 未加载
评论 #5906714 未加载
评论 #5906136 未加载
thu将近 12 年前
I think the sites-available is a debianism, not present on all distros. One nice thing that nginx supports is include directives with wildcards so you can e.g. have &#x2F;srv&#x2F;example.com&#x2F;nginx.conf and &#x2F;srv&#x2F;api.example.com&#x2F;nginx.conf and include them in the main configuration file with include &#x2F;srv&#x2F;*&#x2F;nginx.conf.
评论 #5908603 未加载
评论 #5909451 未加载
评论 #5906687 未加载
评论 #5906724 未加载
评论 #5906951 未加载
评论 #5906749 未加载
tszming将近 12 年前
For starter nginx&#x27;s configuration, the h5bp nginx config [1] is pretty awesome, e.g. sending correct mime types, protecting hidden files, cross domain webfont, expires, gzip, server tunings all included.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;h5bp&#x2F;server-configs&#x2F;tree&#x2F;master&#x2F;nginx" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;h5bp&#x2F;server-configs&#x2F;tree&#x2F;master&#x2F;nginx</a>
评论 #5906700 未加载
286c8cb04bda将近 12 年前
<i>&gt; The default port for the internet is 80, so if there’s no port in a url, that means it’s 80.</i><p>The Internet has no default port; 80 is for HTTP. If the port is omitted, then the default for the scheme[1] is assumed.<p>&lt;&#x2F;pedant&gt;<p>[1]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;URI_scheme" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;URI_scheme</a>
评论 #5906512 未加载
warmwaffles将近 12 年前
I am a little hesitant on restarting nginx. When you do that, it drops the connections that are currently attached. Instead, you may want to do `nginx reload`
评论 #5906437 未加载
评论 #5906467 未加载
callmeed将近 12 年前
One of my favorite nginx features I just discovered is that you can use a regex in the server_name and then you can use the capture as a variable later [1] ... this lets you serve domains or subomains from completely different directories without a new conf file or a reload.<p>I&#x27;m using it at <a href="http:&#x2F;&#x2F;www.utterson.me" rel="nofollow">http:&#x2F;&#x2F;www.utterson.me</a> to serve up static Jekyll blogs on a subdomain.<p>I may be wrong, but I don&#x27;t think Apache can do this (it can do regex but you don&#x27;t get a variable).<p>[1] <a href="http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;server_names.html#regex_names" rel="nofollow">http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;http&#x2F;server_names.html#regex_names</a>
评论 #5906836 未加载
lowboy将近 12 年前
I like just keeping a single &quot;etc&#x2F;nginx&#x2F;sites&quot; folder, including &quot;sites&#x2F;*.ON&quot; in my main nginx.conf and then appending .ON to the sites that are enabled:<p><pre><code> active.site.com.ON another.active.com.ON not.active.com</code></pre>
评论 #5907059 未加载
antocv将近 12 年前
What makes this &quot;for developers&quot;? Whats the difference if a sysadmin is reading this, or a Linux user?<p>Im surprised to see this on the frontpage, it is less than basics in anything any hacker worth its name can do.
评论 #5906783 未加载
评论 #5906728 未加载
评论 #5906668 未加载
chuhnk将近 12 年前
For some strange reason I was expecting an article on nginx module development. <a href="http:&#x2F;&#x2F;www.evanmiller.org&#x2F;nginx-modules-guide.html" rel="nofollow">http:&#x2F;&#x2F;www.evanmiller.org&#x2F;nginx-modules-guide.html</a>
评论 #5908633 未加载
samsnelling将近 12 年前
Completely off-topic: Is that a custom WP theme? I love the look and feel of this article.<p>On-topic: Thank you for this. I am going to purchase a DO box this weekend and play around with nginx instead of apache. For some reason when I last tried to use nginx, I could not get location {} to work. Granted it was some time ago.<p>Does anyone have any resources on nginx as a load balancer?
评论 #5906169 未加载
评论 #5906234 未加载
评论 #5906221 未加载
mfjordvald将近 12 年前
It&#x27;s kinda depressing that this article is basically just a copy of one I wrote in 2010 and it&#x27;s still something that gets attention as interesting stuff. Nginx documentation obviously still has a long way to go.
评论 #5907093 未加载
评论 #5906833 未加载
评论 #5908619 未加载
seclorum将近 12 年前
I&#x27;ve always wanted to use nginx to build web apps in Lua .. does anyone know&#x2F;can recommend any great tutorials with this in mind? It&#x27;d be nice if I could learn how to use nginx+lua to build a blog, and so on .. I&#x27;ll use google, but on the off chance someone on HN knows of something already, I&#x27;m all ears ..
评论 #5908578 未加载
评论 #5908871 未加载
评论 #5909601 未加载
ChikkaChiChi将近 12 年前
This article is just fine for IDE-side development, but I would not recommend for anyone to use the version of nginx in the standard Ubuntu package manager. It traditionally is several version back missing important key features that you might want to take advantage of.
评论 #5907123 未加载
raylu将近 12 年前
Slightly off-topic, but I&#x27;m sad that people still use apt-get. aptitude is pretty much just better[1].<p>Also, if you&#x27;re reading this article you probably don&#x27;t need the slightly better performance&#x2F;throughput of nginx. Nginx&#x27;s configuration is just terrible. You can cause segfaults and all sorts of unexpected behavior with the If directive[2]. And who came up with the idea that rewrite[3] should sometimes redirect instead of rewriting?<p><i>If the replacement string begins with <a href="http:&#x2F;&#x2F;" rel="nofollow">http:&#x2F;&#x2F;</a> then the client will be redirected, and any further rewrite directives are terminated.</i><p>Apache&#x27;s configuration might be ugly and unwieldy and the community might be horribly infested, but at least the configuration makes sense. Lighttpd has none of the above problems, though.<p>[1] <a href="http:&#x2F;&#x2F;superuser.com&#x2F;questions&#x2F;93437&#x2F;" rel="nofollow">http:&#x2F;&#x2F;superuser.com&#x2F;questions&#x2F;93437&#x2F;</a><p>[2] <a href="http:&#x2F;&#x2F;wiki.nginx.org&#x2F;IfIsEvil" rel="nofollow">http:&#x2F;&#x2F;wiki.nginx.org&#x2F;IfIsEvil</a><p>[3] <a href="http:&#x2F;&#x2F;wiki.nginx.org&#x2F;HttpRewriteModule#rewrite" rel="nofollow">http:&#x2F;&#x2F;wiki.nginx.org&#x2F;HttpRewriteModule#rewrite</a>
评论 #5908546 未加载
评论 #5909847 未加载
评论 #5908267 未加载
GibbyBorn将近 12 年前
Guys, don&#x27;t link to the community wiki, it contains a lot of obsolete or just wrong information. Always use official documentation: <a href="http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;" rel="nofollow">http:&#x2F;&#x2F;nginx.org&#x2F;en&#x2F;docs&#x2F;</a>
falsedan将近 12 年前
I like this article because it reaffirms the demand for competent devops who&#x27;ve taken an afternoon to read all of <a href="http:&#x2F;&#x2F;wiki.nginx.org&#x2F;DirectiveIndex" rel="nofollow">http:&#x2F;&#x2F;wiki.nginx.org&#x2F;DirectiveIndex</a>.
geuis将近 12 年前
Just a note on readability. You have a font color of #555 against #fff; Its a light grey against white background and <i>very</i> hard to read.
saravk将近 12 年前
Very nice article useful for Nginx newbies. While we are on that subject, can anyone please let me know if we can use Nginx for page cache busting purposes.<p>It is easy to configure Nginx to check if the cached version of the requested URL exists and serve it. But i would like to know if the configuration can be extended bit further to serve the cached file only if is less than a few days old?
dergachev将近 12 年前
If you liked this, consider checking out Mastering Nginx by Dimitri Aivaliotis. I was quite surprised how helpful this book was.<p><a href="http:&#x2F;&#x2F;www.amazon.com&#x2F;Mastering-Nginx-Dimitri-Aivaliotis&#x2F;dp&#x2F;1849517444" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;Mastering-Nginx-Dimitri-Aivaliotis&#x2F;dp&#x2F;...</a>
matthieupiguet将近 12 年前
Nice introductory article. Maybe it should have included a word about SSL support, especially the fact that you need to build nginx with ssl support, it doesn&#x27;t come out of the box, so make sure you plan for when you&#x27;ll need it
ryandotsmith将近 12 年前
If you are interested in running NGINX on Heroku, checkout my buildpack: <a href="https:&#x2F;&#x2F;github.com&#x2F;ryandotsmith&#x2F;nginx-buildpack" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ryandotsmith&#x2F;nginx-buildpack</a>
DanielBMarkham将近 12 年前
Been thinking about nginx for some time. If I could get an easy Mono&#x2F;F# implementation working with it, I&#x27;d jump on it in a heartbeat.
评论 #5906552 未加载
评论 #5906615 未加载
评论 #5906574 未加载
klearvue将近 12 年前
In the example given &quot;listen 80;&quot; is completely unnecessary since it&#x27;s a default.
评论 #5907460 未加载
w0ts0n将近 12 年前
&quot; nginx (pronounced engine-x). &quot;<p>I have literally never heard anyone call it that.
评论 #5907842 未加载
评论 #5908040 未加载
评论 #5907811 未加载
评论 #5908429 未加载
diminoten将近 12 年前
This is fantastic, thank you! The way it&#x27;s written is great because it doesn&#x27;t treat me like an idiot (I get why books do that, but it can grow tiresome). I wish more tech books were written like this.<p>While we&#x27;re picking nits, I thought this might be worth mentioning:<p>&gt; The default port for the internet is 80<p>I&#x27;d change that to:<p>&gt; The default port for the web is 80<p>Again, wonderful guide!