内容简介:我们的基础设施中有一些运行NGINX的FreeBSD机器。在F5 最近我们看到很多开源项目在被收购后表现并不是那么良好,我们认为这次收购不会对项目有利。几年前
我们的基础设施中有一些运行NGINX的FreeBSD机器。在F5 最近 宣布 购买NGINX之后,我们决定回到 Lighttpd 。
我们看到很多开源项目在被收购后表现并不是那么良好,我们认为这次收购不会对项目有利。
几年前 Lighttpd 项目停滞不前,它让我们转向NGINX。最近几年它再次活跃起来,我们决定退回去。
在这篇文章中,我们描述了 Lighttpd 配置,以涵盖NGINX上的所有用途。
Lighttpd 中的许多选项都是通过使用 模块 启用的。这些是我们在所有 Lighttpd 服务器上启用的 模块 。
server.modules = ( <font>"mod_auth"</font><font>, </font><font>"mod_expire"</font><font>, </font><font>"mod_compress"</font><font>, </font><font>"mod_rewrite"</font><font>, </font><font>"mod_redirect"</font><font>, </font><font>"mod_alias"</font><font>, </font><font>"mod_access"</font><font>, </font><font>"mod_setenv"</font><font>, </font><font>"mod_evhost"</font><font>, </font><font>"mod_fastcgi"</font><font>, </font><font>"mod_accesslog"</font><font>, </font><font>"mod_openssl"</font><font> ) </font>
指定 Lighttpd 侦听的IP和端口是以几种不同的方式定义的。对于IPv4 server.port和server.bind。对于IPv6,您必须使用$ SERVER [“socket”]。SSL配置也是如此。
server.port = <font>"80"</font><font>
server.bind = </font><font>"0.0.0.0"</font><font>
$SERVER[</font><font>"socket"</font><font>] == </font><font>"[::]:80"</font><font> { }
$SERVER[</font><font>"socket"</font><font>] == </font><font>"[::]:443"</font><font> { }
$SERVER[</font><font>"socket"</font><font>] == </font><font>":443"</font><font> {
ssl.engine = </font><font>"enable"</font><font>
ssl.pemfile = </font><font>"/usr/local/etc/ssl/certs/example.com/combined.pem"</font><font>
ssl.ca-file = </font><font>"/usr/local/etc/ssl/certs/example.com/chain.pem"</font><font>
ssl.cipher-list = </font><font>"EECDH+AESGCM:EDH+AESGCM:AES128+EECDH:AES128+EDH"</font><font>
ssl.dh-file = </font><font>"/usr/local/etc/ssl/certs/dhparam.pem"</font><font>
ssl.ec-curve = </font><font>"secp384r1"</font><font>
setenv.add-response-header = (</font><font>"Strict-Transport-Security"</font><font> => </font><font>"max-age=31536000; includeSubdomains"</font><font>)
}
</font>
Lighttpd 需要PEM证书。您可以轻松创建:
# cat domain.key domain.crt > combined.pem
您可以使用以下命令创建dhparam.pem文件:
# openssl dhparam -out dhparam.pem 4096
这些是我们在FreeBSD上使用的与服务器设置相关的全局设置。
server.username = <font>"www"</font><font> server.groupname = </font><font>"www"</font><font> server.pid-file = </font><font>"/var/run/lighttpd.pid"</font><font> server.event-handler = </font><font>"freebsd-kqueue"</font><font> server.stat-cache-engine = </font><font>"disable"</font><font> server.max-write-idle = 720 server.tag = </font><font>"lighttpd"</font><font> server.document-root = </font><font>"/usr/local/www/default/"</font><font> server.error-handler-404 = </font><font>"/404.html"</font><font> accesslog.filename = </font><font>"/usr/local/www/logs/lighttpd.access.log"</font><font> server.errorlog = </font><font>"/usr/local/www/logs/lighttpd.error.log"</font><font> server.dir-listing = </font><font>"disable"</font><font> </font>
一些适用于 Lighttpd 服务的所有网站的全局设置。
index-file.names = (<font>"index.php"</font><font>, </font><font>"index.html"</font><font>, </font><font>"index.htm"</font><font>) url.access-deny = (</font><font>"~"</font><font>, </font><font>".inc"</font><font>, </font><font>".sh"</font><font>, </font><font>"sql"</font><font>, </font><font>".htaccess"</font><font>) <b>static</b>-file.exclude-extensions = (</font><font>".php"</font><font>, </font><font>".pl"</font><font>, </font><font>".fcgi"</font><font>) </font>
让我们加密的别名。
alias.url += (<font>"/.well-known/acme-challenge/"</font><font> => </font><font>"/usr/local/www/acme/"</font><font>) </font>
为某些文件类型启用压缩。
compress.cache-dir = <font>"/tmp/lighttpdcompress/"</font><font> compress.filetype = (</font><font>"text/plain"</font><font>, </font><font>"text/css"</font><font>, </font><font>"text/xml"</font><font>, </font><font>"text/javascript"</font><font>) </font>
需要身份验证时,您可以指定如下。支持不同的后端。
auth.backend = <font>"htpasswd"</font><font> auth.backend.htpasswd.userfile = </font><font>"/usr/local/etc/lighttpd/htpasswd"</font><font> </font>
某些文件类型的常规Expire和Cache-Control标头。
$HTTP[<font>"url"</font><font>] =~ </font><font>"\.(js|css|png|jpg|jpeg|gif|ico)$"</font><font> {
expire.url = ( </font><font>""</font><font> => </font><font>"access plus 1 months"</font><font> )
}
</font>
当您运行Wordpress网站时,您可能想要拒绝访问某些网址。
$HTTP[<font>"url"</font><font>] =~ </font><font>"/(?:uploads|files|wp-content|wp-includes).*\.(php|phps|txt|md|exe)$"</font><font> {
url.access-deny = (</font><font>""</font><font>)
}
$HTTP[</font><font>"url"</font><font>] =~ </font><font>"/(wp-config|xmlrpc)\.php$"</font><font> {
url.access-deny = (</font><font>""</font><font>)
}
</font>
定义需要身份验证的主机和URL。
$HTTP[<font>"host"</font><font>] =~ </font><font>"www1.example.com"</font><font> {
auth.require = ( </font><font>"/admin/"</font><font> => (
</font><font>"method"</font><font> => </font><font>"basic"</font><font>,
</font><font>"realm"</font><font> => </font><font>"Restricted"</font><font>,
</font><font>"require"</font><font> => </font><font>"valid-user"</font><font> )
)
}
</font>
将某些主机从http重定向到https。
$HTTP[<font>"host"</font><font>] =~ </font><font>"(www\.)?example.com"</font><font> {
url.redirect = (</font><font>"^/(.*)"</font><font> => </font><font>"https://www.example.com/$1"</font><font>)
}
</font>
有一个可用的模块可以帮助为虚拟主机分配正确的server.document-root。这可以使用 mod_evhost 完成,我们使用以下模式:
$HTTP[<font>"host"</font><font>] =~ </font><font>"^(www.)?[^.]+\.[^.]+$"</font><font> {
evhost.path-pattern = </font><font>"/usr/local/www/www.%2.%1/"</font><font>
}
</font>
为了能够使用Wordpress的漂亮网址,您可以使用以下 mod_rewrite 规则。
url.rewrite = ( <font>"^/(.*)\.(.+)$"</font><font> => </font><font>"$0"</font><font>, </font><font>"^/(.+)/?$"</font><font> => </font><font>"/index.php/$1"</font><font> ) </font>
当您使用PHP-FPM时,最后一块拼图可以使用以下配置。
fastcgi.server = ( <font>".php"</font><font> =>
( </font><font>"localhost"</font><font> =>
(
</font><font>"host"</font><font> => </font><font>"127.0.0.1"</font><font>,
</font><font>"port"</font><font> => 9000
)
)
)
</font>
完整的配置可以在我们的 Git存储库中 找到
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 回到未来:永恒的lisp
- Istiod——回到单体的理由
- [译] Istiod:回到单体的理由
- 用关系型 NoSQL 回到未来
- 回到基础:如何用原生 DOM API 生成表格
- 从Rails到Clojure再到Java,最后回到Rails
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Web Design Handbook
Baeck, Philippe de 编 / 2009-12 / $ 22.54
This non-technical book brings together contemporary web design's latest and most original creative examples in the areas of services, media, blogs, contacts, links and jobs. It also traces the latest......一起来看看 《Web Design Handbook》 这本书的介绍吧!
HEX CMYK 转换工具
HEX CMYK 互转工具
HEX HSV 转换工具
HEX HSV 互换工具