`

20个Nginx Web服务器最佳安全实践

阅读更多
<p>www.myhack58.com/Article/60/61/2010/26994.htm</p>
<p><strong>20个Nginx Web服务器最佳安全实践</strong>

</p>
<p>Nginx是一个轻量级,高性能的Web服务器/反向代理和电子邮件代理(IMAP/POP3),它可以运行在UNIX,GNU
/Linux,BSD变种,MAC OS X,Solaris和Microsoft
Windows上。根据Netcraft的调查数据显示,互联网上6%的域名都使用了Nginx
Web服务器。Nginx是解决C10K问题的服务器之一,与传统服务器不一样,Nginx不依赖于线程处理请求,相反,它使用了一个更具扩展性的事件驱
动(异步)架构。Nginx在很多高流量网站上得到了应用,如WordPress,Hulu,Github和SourceForge。</p>
<p>本文的主要目是介绍如何提高运行在Linux或UNIX类操作系统上的Nginx Web服务器的安全性。</p>
<p>Nginx默认配置文件和默认端口</p>
<p>◆ /usr/local/nginx/conf/ - Nginx服务器配置目录,/usr/local/nginx/conf/nginx.conf 是主配置文件</p>
<p>◆ /usr/local/nginx/html/ - 默认文档位置</p>
<p>◆ /usr/local/nginx/logs/ - 默认日志文件位置</p>
<p>◆ Nginx HTTP默认端口:TCP 80</p>
<p>◆ Nginx HTTPS默认端口:TCP 443</p>
<p>可以使用下面的命令测试Nginx的配置是否正确:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># /usr/local/nginx/sbin/nginx –t
</pre>
</td>
</tr></tbody></table>
<p>输出示例:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok</pre>
<pre>configuration file /usr/local/nginx/conf/nginx.conf test is successful</pre>
</td>
</tr></tbody></table>
<p>要让修改后的配置生效,执行下面的命令:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># /usr/local/nginx/sbin/nginx -s reload
</pre>
</td>
</tr></tbody></table>
<p>如果要停止服务器,运行:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># /usr/local/nginx/sbin/nginx -s stop
</pre>
</td>
</tr></tbody></table>
<p><strong>1、开启SELinux</strong>
</p>
<p>SELinux(安全增强的Linux)是一个Linux内核功能,它提供了一个机制支持访问控制安全策略,提供了巨大的安全保护能力,它可以防止大多数系统root级攻击,请参考“如何在CentOS/Red Hat系统上开启SELinux”(<a href="http://www.cyberciti.biz/faq/rhel-fedora-redhat-selinux-protection/">http://www.cyberciti.biz/faq/rhel-fedora-redhat-selinux-protection/</a>
)。</p>
<p>运行getsebool –a命令查看SELinux设置项:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>getsebool -a | less</pre>
<pre>getsebool -a | grep off</pre>
<pre>getsebool -a | grep o</pre>
</td>
</tr></tbody></table>
<p>然后使用setsebool命令开启需要的配置项,注意:开启SELinux后,在RHEL或CentOS上通常会增加2-8%的系统开销。</p>
<p><strong>2、通过mount参数提供最低权限</strong>
</p>
<p>为你的/html/php文件创建独立的分区,例如,创建一个/dev/sda5分区挂载在/ngnix上,确定/ngnix使用了noexec,nodev和nosetuid权限挂载。下面是我的一个挂载实例:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>LABEL=/nginx     </pre>
<pre>/nginx          </pre>
<pre>ext3   </pre>
<pre>defaults,nosuid,noexec,nodev 1 2</pre>
</td>
</tr></tbody></table>
<p>注意你需要使用fdisk和mkfs.ext3命令创建一个新分区。</p>
<p><strong>3、通过/etc/sysctl.conf加固</strong>
</p>
<p>可以通过/etc/sysctl.conf控制和配置Linux内核及网络设置。</p>
<p>另外,请参考:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># 避免放大攻击</pre>
<pre>net.ipv4.icmp_echo_ignore_broadcasts = 1</pre>
<pre># 开启恶意icmp错误消息保护</pre>
<pre>net.ipv4.icmp_ignore_bogus_error_responses = 1</pre>
<pre># 开启SYN洪水攻击保护</pre>
<pre>net.ipv4.tcp_syncookies = 1</pre>
<pre># 开启并记录欺骗,源路由和重定向包</pre>
<pre>net.ipv4.conf.all.log_martians = 1</pre>
<pre>net.ipv4.conf.default.log_martians = 1</pre>
<pre># 处理无源路由的包</pre>
<pre>net.ipv4.conf.all.accept_source_route = 0</pre>
<pre>net.ipv4.conf.default.accept_source_route = 0

# 开启反向路径过滤</pre>
<p>net.ipv4.conf.all.rp_filter = 1</p>
<p>net.ipv4.conf.default.rp_filter = 1</p>
<p># 确保无人能修改路由表</p>
<p>net.ipv4.conf.all.accept_redirects = 0</p>
<p>net.ipv4.conf.default.accept_redirects = 0</p>
<p>net.ipv4.conf.all.secure_redirects = 0</p>
<p>net.ipv4.conf.default.secure_redirects = 0</p>
<p># 不充当路由器</p>
<p>net.ipv4.ip_forward = 0</p>
<p>net.ipv4.conf.all.send_redirects = 0</p>
<p>net.ipv4.conf.default.send_redirects = 0</p>
<p># 开启execshild</p>
<p>kernel.exec-shield = 1</p>
<p>kernel.randomize_va_space = 1</p>
<p># IPv6设置</p>
<p>net.ipv6.conf.default.router_solicitations = 0</p>
<p>net.ipv6.conf.default.accept_ra_rtr_pref = 0</p>
<p>net.ipv6.conf.default.accept_ra_pinfo = 0</p>
<p>net.ipv6.conf.default.accept_ra_defrtr = 0</p>
<p>net.ipv6.conf.default.autoconf = 0</p>
<p>net.ipv6.conf.default.dad_transmits = 0</p>
<p>net.ipv6.conf.default.max_addresses = 1</p>
<p># 优化LB使用的端口</p>
<p># 增加系统文件描述符限制</p>
<p>fs.file-max = 65535</p>
<p># 允许更多的PIDs (减少滚动翻转问题); may break some programs 32768</p>
<p>kernel.pid_max = 65536</p>
<p># 增加系统IP端口限制</p>
<p>net.ipv4.ip_local_port_range = 2000 65000</p>
<p># 增加TCP最大缓冲区大小</p>
<p>net.ipv4.tcp_rmem = 4096 87380 8388608</p>
<p>net.ipv4.tcp_wmem = 4096 87380 8388608</p>
<p># 增加Linux自动调整TCP缓冲区限制</p>
<p># 最小,默认和最大可使用的字节数</p>
<p># 最大值不低于4MB,如果你使用非常高的BDP路径可以设置得更高</p>
<p># Tcp窗口等</p>
<p>net.core.rmem_max = 8388608</p>
<p>net.core.wmem_max = 8388608</p>
<p>net.core.netdev_max_backlog = 5000</p>
<p>net.ipv4.tcp_window_scaling = 1</p>
</td>
</tr></tbody></table>
<p>◆ Linux VM调优(内存)子系统(<a href="http://www.cyberciti.biz/faq/linux-kernel-tuning-virtual-memory-subsystem/">http://www.cyberciti.biz/faq/linux-kernel-tuning-virtual-memory-subsystem/</a>
)</p>
<p>◆ Linux网络堆栈调优(缓冲区大小)提高网络性能(<a href="http://www.cyberciti.biz/faq/linux-tcp-tuning/">http://www.cyberciti.biz/faq/linux-tcp-tuning/</a>
)</p>
<p><strong>4、移除所有不需要的Nginx模块</strong>
</p>
<p>你需要最大限度地将Nginx加载的模块最小化,我的意思是满足Web服务器需要就可以了,多余的模块一个不留,例如,禁用SSI和autoindex模块的命令如下:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># ./configure --without-http_autoindex_module --without-http_ssi_module</pre>
<pre># make</pre>
<pre># make install</pre>
</td>
</tr></tbody></table>
<p>在编译Nginx服务器时,使用下面的命令查看哪些模块应该启用,哪些模块应该禁用:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre><p class="a" style="text-indent: 18pt; margin: 0cm 0cm 0pt;"><span style="background-color: #d9d9d9; color: #0000ff; font-size: x-small;"># ./configure --help | less</span>
</p>
</pre>
</td>
</tr></tbody></table>
<p>禁用你不需要的Nginx模块。</p>
<p>修改Nginx版本头信息(可选),编辑src/http/ngx_http_header_filter_module.c:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># vi +48 src/http/ngx_http_header_filter_module.c
</pre>
</td>
</tr></tbody></table>
<p>找到下面两行:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>static char ngx_http_server_string[] = "Server: nginx" CRLF;</pre>
<pre>static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;</pre>
</td>
</tr></tbody></table>
<p>将其修改为:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>static char ngx_http_server_string[] = "Server: Ninja Web Server" CRLF;</pre>
<pre>static char ngx_http_server_full_string[] = "Server: Ninja Web Server" CRLF;</pre>
</td>
</tr></tbody></table>
<p>保存并关闭文件。现在可以开始编译服务器了,将下面的配置代码添加到nginx.conf中,禁止在所有自动产生的错误页面中显示Nginx版本号:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>server_tokens off</pre>
</td>
</tr></tbody></table>
<p><strong>5、使用mod_security(仅适用于后端Apache服务器)</strong>
</p>
<p>Mod_security为Apache提供了一个应用程序级防火墙,为所有后端Apache Web服务器安装mod_security模块,可以阻止许多注入攻击。</p>
<p><strong>6、配置SELinux策略加固Nginx</strong>
</p>
<p>默认情况下,SELinux没有保护Nginx Web服务器,可以手动配置进行保护,首先安装SELinux编译时需要的支持包:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># yum -y install selinux-policy-targeted selinux-policy-devel</pre>
</td>
</tr></tbody></table>
<p>从项目主页(<a href="http://sourceforge.net/projects/selinuxnginx/">http://sourceforge.net/projects/selinuxnginx/</a>
)下载SELinux策略:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># cd /opt</pre>
<pre># wget 'http://downloads.sourceforge.net/project/selinuxnginx/se-ngix_1_0_10.tar.</pre>
<pre>gz?use_mirror=nchc'</pre>
</td>
</tr></tbody></table>
<p> </p>
<p>解压:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># tar -zxvf se-ngix_1_0_10.tar.gz
</pre>
</td>
</tr></tbody></table>
<p>编译:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># cd se-ngix_1_0_10/nginx</pre>
<pre># make</pre>
</td>
</tr></tbody></table>
<p>输出示例:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>Compiling targeted nginx module</pre>
<pre>/usr/bin/checkmodule:  loading policy configuration from tmp/nginx.tmp</pre>
<pre>/usr/bin/checkmodule:  policy configuration loaded</pre>
<pre>/usr/bin/checkmodule:  writing binary representation (version 6) to tmp/nginx.mod</pre>
<pre>Creating targeted nginx.pp policy package</pre>
<pre>rm tmp/nginx.mod.fc tmp/nginx.mod</pre>
</td>
</tr></tbody></table>
<p>安装生成的nginx.pp SELinux模块:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre><p class="a" style="text-indent: 18pt; margin: 0cm 0cm 0pt;"><span style="background-color: #d9d9d9; color: #0000ff; font-size: x-small;"># /usr/sbin/semodule -i nginx.pp</span>
</p>
</pre>
</td>
</tr></tbody></table>
<p><strong>7、通过iptables防火墙设置限制</strong>
</p>
<p>下面的防火墙脚本可以阻止一切请求,只允许:</p>
<p>◆ 入站HTTP请求(TCP 80端口)</p>
<p>◆ 入站ICMP ping请求</p>
<p>◆ 出站NTP请求(端口123)</p>
<p>◆ 出站SMTP请求(TCP端口25)</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>#!/bin/bash</pre>
<pre>IPT="/sbin/iptables"</pre>
<pre>#### IPS ######</pre>
<pre># 获得服务器公共IP</pre>
<pre>SERVER_IP=$(ifconfig eth0 | grep 'inet addr:' | awk -F'inet addr:' '{ print $2}' | awk '{ print $1}')</pre>
<pre>LB1_IP="204.54.1.1"</pre>
<pre>LB2_IP="204.54.1.2"</pre>
<pre># 实现某些智能逻辑,以便我们可以在LB2上使用damm脚本</pre>
<pre>OTHER_LB=""</pre>
<pre>SERVER_IP=""</pre>
<pre>[[ "$SERVER_IP" == "$LB1_IP" ]] &amp;&amp; OTHER_LB="$LB2_IP" || OTHER_LB="$LB1_IP"</pre>
<pre>[[ "$OTHER_LB" == "$LB2_IP" ]] &amp;&amp; OPP_LB="$LB1_IP" || OPP_LB="$LB2_IP"</pre>
<pre>### IPs ###</pre>
<pre>PUB_SSH_ONLY="122.xx.yy.zz/29" #### 文件 #####</pre>
<p>BLOCKED_IP_TDB=/root/.fw/blocked.ip.txt</p>
<p>SPOOFIP="127.0.0.0/8 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8
169.254.0.0/16 0.0.0.0/8 240.0.0.0/4 255.255.255.255/32 168.254.0.0/16
224.0.0.0/4 240.0.0.0/5 248.0.0.0/5 192.0.2.0/24"</p>
<p>BADIPS=$( [[ -f ${BLOCKED_IP_TDB} ]] &amp;&amp; egrep -v "^#|^$" ${BLOCKED_IP_TDB})</p>
<p>### 接口 ###</p>
<p>PUB_IF="eth0"   # public interface</p>
<p>LO_IF="lo"      # loopback</p>
<p>VPN_IF="eth1"   # vpn / private net</p>
<p>### 启动防火墙 ###</p>
<p>echo "Setting LB1 $(hostname) Firewall..."</p>
<p># 删除和关闭一切</p>
<p>$IPT -P INPUT DROP</p>
<p>$IPT -P OUTPUT DROP</p>
<p>$IPT -P FORWARD DROP</p>
<p># 不受限制的lo访问</p>
<p>$IPT -A INPUT -i ${LO_IF} -j ACCEPT</p>
<p>$IPT -A OUTPUT -o ${LO_IF} -j ACCEPT</p>
<p># 不受限制的vpn/pnet访问</p>
<p>$IPT -A INPUT -i ${VPN_IF} -j ACCEPT</p>
<p>$IPT -A OUTPUT -o ${VPN_IF} -j ACCEPT</p>
<p># 删除sync</p>
<p>$IPT -A INPUT -i ${PUB_IF} -p tcp ! --syn -m state --state NEW -j DROP</p>
<p># 删除碎片</p>
<p>$IPT -A INPUT -i ${PUB_IF} -f -j DROP</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL ALL -j DROP</p>
<p># 删除空包</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL NONE -m limit
--limit 5/m --limit-burst 7 -j LOG --log-prefix " NULL Packets "</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL NONE -j DROP</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,RST SYN,RST -j DROP</p>
<p># 删除XMAS</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,FIN SYN,FIN -m
limit --limit 5/m --limit-burst 7 -j LOG --log-prefix " XMAS Packets "</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP</p>
<p># 删除FIN包扫描</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags FIN,ACK FIN -m limit
--limit 5/m --limit-burst 7 -j LOG --log-prefix " Fin Packets Scan "</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags FIN,ACK FIN -j DROP</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP</p>
<p># 记录并放弃广播/多播和无效数据包</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -m pkttype --pkt-type broadcast -j LOG --log-prefix " Broadcast "</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -m pkttype --pkt-type broadcast -j DROP</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -m pkttype --pkt-type multicast -j LOG --log-prefix " Multicast "</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -m pkttype --pkt-type multicast -j DROP</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -m state --state INVALID -j LOG --log-prefix " Invalid "</p>
<p>$IPT  -A INPUT -i ${PUB_IF} -m state --state INVALID -j DROP</p>
<p># 记录和阻止欺骗IP</p>
<p>$IPT -N spooflist</p>
<p>for ipblock in $SPOOFIP</p>
<p>do    </p>
<p>$IPT -A spooflist -i ${PUB_IF} -s $ipblock -j LOG --log-prefix " SPOOF List Block "       </p>
<p>$IPT -A spooflist -i ${PUB_IF} -s $ipblock -j DROP</p>
<p>done</p>
<p>$IPT -I INPUT -j spooflist</p>
<p>$IPT -I OUTPUT -j spooflist</p>
<p>$IPT -I FORWARD -j spooflist</p>
<p># 只允许从选定的公共IP使用SSH</p>
<p>for ip in ${PUB_SSH_ONLY}</p>
<p>do        $IPT -A INPUT -i ${PUB_IF} -s ${ip} -p tcp -d ${SERVER_IP} --destination-port 22 -j ACCEPT       </p>
<p>$IPT -A OUTPUT -o ${PUB_IF} -d ${ip} -p tcp -s ${SERVER_IP} --sport 22 -j ACCEPT</p>
<p>done</p>
<p># 允许入站ICMP ping</p>
<p>$IPT -A INPUT -i ${PUB_IF} -p icmp --icmp-type 8 -s 0/0 -m state
--state NEW,ESTABLISHED,RELATED -m limit --limit 30/sec  -j ACCEPT</p>
<p>$IPT -A OUTPUT -o ${PUB_IF} -p icmp --icmp-type 0 -d 0/0 -m state --state ESTABLISHED,RELATED -j ACCEPT</p>
<p># 允许入站HTTP端口80</p>
<p>$IPT -A INPUT -i ${PUB_IF} -p tcp -s 0/0 --sport 1024:65535 --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT</p>
<p>$IPT -A OUTPUT -o ${PUB_IF} -p tcp --sport 80 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT</p>
<p># 允许出站NTP</p>
<p>$IPT -A OUTPUT -o ${PUB_IF} -p udp --dport 123 -m state --state NEW,ESTABLISHED -j ACCEPT</p>
<p>$IPT -A INPUT -i ${PUB_IF} -p udp --sport 123 -m state --state ESTABLISHED -j ACCEPT</p>
<p># 允许出站SMTP</p>
<p>$IPT -A OUTPUT -o ${PUB_IF} -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT</p>
<p>$IPT -A INPUT -i ${PUB_IF} -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT</p>
<p>### 在这里添加其他规则 ####</p>
<p>#######################</p>
<p># 删除并记录其它数据包</p>
<p>$IPT -A INPUT -m limit --limit 5/m --limit-burst 7 -j LOG --log-prefix " DEFAULT DROP "</p>
<p>$IPT -A INPUT -j DROP</p>
<p>exit 0</p>
</td>
</tr></tbody></table>
<p><strong>8、控制缓冲区溢出攻击</strong>
</p>
<p> </p>
<p>编辑nginx.conf设置所有客户端可用的缓冲区大小限制:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># vi /usr/local/nginx/conf/nginx.conf
</pre>
</td>
</tr></tbody></table>
<p>具体设置如下:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>## Start: Size Limits &amp; Buffer Overflows ##  client_body_buffer_size  1K;

client_header_buffer_size 1k;  client_max_body_size 1k;  large_client_header_buffers 2 1k; </pre>
<pre>## END: Size Limits &amp; Buffer Overflows ##</pre>
</td>
</tr></tbody></table>
<p>说明:</p>
<p>client_body_buffer_size 1k:默认是8k或16k,指定客户端请求主体缓冲区大小。</p>
<p>client_header_buffer_size 1k:指定来自客户端请求头的headerbuffer大小,对于大多数请求,1k的缓冲区大小已经足够,如果你自定义了消息头或有更大的Cookie,你可以增加其大小。</p>
<p>client_max_body_size
1k:客户端请求中可接受的主体最大大小,由请求头中的Content-Length表示,如果大小大于给定的尺寸,客户端将会收到一条“Request
Entity Too Large(413)”的错误,如果你要通过POST方法上传文件,可以将该值设大一些。</p>
<p>large_client_header_buffers 2
1k:为客户端请求中较大的消息头指定的缓存最大数量和大小,默认情况下,一个缓冲区的大小等于页面的大小,根据平台的不同可能是4K或8K,如果在请求
连接的末尾状态转换为保持活动(keep-alive),这些缓冲区就被释放,2x1K将可以接收2KB数据的URI,这样有助于打击机器人攻击和DoS
攻击。</p>
<p>另外,你还需要控制超时时间,提高服务器性能,降低客户端的等待时间,做如下修改:</p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>## Start: Timeouts </pre>
<pre>##  client_body_timeout   </pre>
<pre>10;  client_header_timeout 10;

keepalive_timeout     </pre>
<pre>5 5;  send_timeout          </pre>
<pre>10;</pre>
<p>## End: Timeouts ##</p>
</td>
</tr></tbody></table>
<p>client_body_timeout 10:设置客户端请求主体读取超时时间,如果在这个时间后客户端还没有发送任何数据,Nginx返回“Request time out(408)”错误,默认值是60。</p>
<p>client_header_timeout 10:设置客户端请求头读取超时时间,如果在这个时间后客户端还没有发送任何数据,Nginx返回“Request time out(408)”错误。</p>
<p>keepalive_timeout 5
5:第一个参数指定客户端连接保持活动的超时时间,在这个时间之后,服务器会关掉连接,第二个参数是可选的,它指定了消息头保持活动的有效时间,即响应中
的timeout=time,它可以告诉某些浏览器关闭连接,因此服务器就不必关闭连接了,如果没有这个参数,Nginx不会发送Keep-Alive
头。</p>
<p>send_timeout 10:指定响应客户端的超时时间,这个超时仅限于两个阅读活动之间的时间,如果这个时间后客户端没有任何活动,Nginx将会关闭连接。</p>
<p><strong>9、控制并发连接</strong>
</p>
<p>你可以使用NginxHttpLimitZone模块限制指定会话,或某个IP的并发连接数,编辑nginx.conf:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>### Directive describes the zone, in which the session states are stored i.e. store in slimits. </pre>
<pre>### 1m can handle 32000 sessions with 32 bytes/session, set to 5m x 32000 session ###

limit_zone slimits $binary_remote_addr 5m;

### Control maximum number of simultaneous connections for one session i.e. ###</pre>
<p>### restricts the amount of connections from a single ip address ###<br><br>
limit_conn slimits 5;</p>
</td>
</tr></tbody></table>
<p>上述设置可以限制远程客户端每IP地址不能超过5个同时打开的连接。</p>
<p><strong>10、只允许访问指定的域名</strong>
</p>
<p>如果有机器人程序在随机扫描所有域,那就阻止它访问,你必须配置只允许虚拟域或反向代理请求。</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>## Only requests to our Host are allowed i.e. nixcraft.in, images.nixcraft.in and <a href="http://www.nixcraft.in/">www.nixcraft.in</a>
   </pre>
<pre>if ($host !~ ^(nixcraft.in|www.nixcraft.in|images.nixcraft.in)$ ) {         </pre>
<pre>return 444;      }</pre>
<p>##</p>
</td>
</tr></tbody></table>
<p><strong>11、限制可用的方法</strong>
</p>
<p>GET和POST是互联网上最常用的方法,RFC 2616定义了Web服务器可用的方法,如果一个Web服务器不要求实现所有方法,那些方法就应该被禁止掉,下面的代码将过滤所有方法,只允许GET,HEAD和POST方法:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>## Only allow these request methods ##     </pre>
<pre>if ($request_method !~ ^(GET|HEAD|POST)$ ) {         </pre>
<pre>return 444;     }</pre>
<p>## Do not accept DELETE, SEARCH and other methods ##</p>
</td>
</tr></tbody></table>
<p>关于HTTP方法的更多信息:</p>
<p>GET方法用于请求文档,如<a href="http://www.cyberciti.biz/index.php">http://www.cyberciti.biz/index.php</a>
。</p>
<p>HEAD方法与GET相同,但服务器不会在响应中只返回消息主体。</p>
<p>POST方法功能就多了,如通过表单存储或更新数据,订购一个产品,发送电子邮件等,通常使用服务器端脚本(如PHP,Perl,Python等)处理,如果你要上传文件或在服务器上处理表单就必须用它。</p>
<p><strong>12a、如何阻止某些用户代理(User-Agents)?</strong>
</p>
<p>你可以轻松阻止用户代理,如扫描器,机器人和垃圾邮件,它们可能会滥用你的服务器。</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>## Block download agents ##     </pre>
<pre>if ($http_user_agent ~* LWP::Simple|BBBike|wget) {         </pre>
<pre>return 403;     }</pre>
<p>##</p>
</td>
</tr></tbody></table>
<p>阻止msnbot和scrapbot机器人:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>## Block some robots ##     </pre>
<pre>if ($http_user_agent ~* msnbot|scrapbot) {           </pre>
<pre>return 403;     }</pre>
</td>
</tr></tbody></table>
<p><strong>12b、如何阻止被提名的垃圾邮件</strong>
</p>
<p>被提名的垃圾邮件都很危险,它们可能会损害你的SEO排名,可以使用下面的代码阻止访问垃圾邮件发送者:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>## Deny certain Referers ###   </pre>
<pre>if ( $http_referer ~* (babes|forsale|girl|jewelry|love|nudit|organic|poker|porn|sex|teen) )     </pre>
<pre>{        </pre>
<pre># return 404;        </pre>
<pre>return 403;     }</pre>
<p>##</p>
</td>
</tr></tbody></table>
<p><strong>13、如何停止图片热链</strong>
</p>
<p>图片或HTML热链是指有人在他们的网站上引用了你网站的图片,你必须为其它网站的流量支付贷款费用,有点象是网站劫持,通常这种情况发生在博</p>
<p>客和论坛中,我强烈建议你在服务器级停止并阻止图片热链。</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># Stop deep linking or hot linking</pre>
<pre>location /images/ {  valid_referers none blocked <a href="http://www.example.com/">www.example.com</a>
example.com;   </pre>
<pre>if ($invalid_referer) {     </pre>
<pre>return   403;   }</pre>
<p>}</p>
</td>
</tr></tbody></table>
<p>例子:重写并显示禁令图片:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>valid_referers blocked <a href="http://www.example.com/">www.example.com</a>
example.com; </pre>
<pre>if ($invalid_referer) { rewrite ^/images/uploads.*\.(gif|jpg|jpeg|png)$ </pre>
<pre><a href="http://www.examples.com/banned.jpg">http://www.examples.com/banned.jpg</a>
last</pre>
<p>}</p>
</td>
</tr></tbody></table>
<p>另外,请参考“How-to:使用Nginx映射阻止图片热链”(<a href="http://nginx.org/pipermail/nginx/2007-June/001082.html">http://nginx.org/pipermail/nginx/2007-June/001082.html</a>
)。</p>
<p><strong>14、目录限制</strong>
</p>
<p>你可以为特定目录设置访问控制,所有网页目录都应配置为按需访问。</p>
<p>通过IP地址限制访问,你可以限制访问/docs/目录的IP地址:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>location /docs/ {  ## block one workstation  deny    192.168.1.1;</pre>
<p>## allow anyone in 192.168.1.0/24  allow   192.168.1.0/24;</p>
<p>## drop rest of the world  deny    all;</p>
<p>}</p>
</td>
</tr></tbody></table>
<p>通过密码保护目录,首先创建一个密码文件,再添加一个用户vivek:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># mkdir /usr/local/nginx/conf/.htpasswd/</pre>
<pre># htpasswd -c /usr/local/nginx/conf/.htpasswd/passwd vivek</pre>
</td>
</tr></tbody></table>
<p>编辑nginx.conf添加需要保护的目录:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>### Password Protect /personal-images/ and /delta/ directories ###</pre>
<pre>location ~ /(personal-images/.*|delta/.*) {  auth_basic  "Restricted";  </pre>
<pre>auth_basic_user_file   /usr/local/nginx/conf/.htpasswd/passwd;</pre>
<p>}</p>
</td>
</tr></tbody></table>
<p>创建好密码文件后,后面的用户可以使用下面的命令进行追加:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># htpasswd -s /usr/local/nginx/conf/.htpasswd/passwd userName
</pre>
</td>
</tr></tbody></table>
<p><br><strong>15、Nginx SSL配置</strong>
</p>
<p> </p>
<p>HTTP是一个纯文本协议,很容易被监听,你应该使用SSL加密传输的信息。</p>
<p>首先需要创建一个SSL证书,输入下面的命令:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># cd /usr/local/nginx/conf</pre>
<pre># openssl genrsa -des3 -out server.key 1024</pre>
<pre># openssl req -new -key server.key -out server.csr</pre>
<pre># cp server.key server.key.org</pre>
<pre># openssl rsa -in server.key.org -out server.key</pre>
<pre># openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt</pre>
</td>
</tr></tbody></table>
<p>编辑nginx.conf,找到对应位置,做如下修改:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>server {    </pre>
<pre>server_name example.com;    </pre>
<pre>listen 443;    </pre>
<pre>ssl on;    </pre>
<pre>ssl_certificate /usr/local/nginx/conf/server.crt;    </pre>
<pre>ssl_certificate_key /usr/local/nginx/conf/server.key;    </pre>
<pre>access_log /usr/local/nginx/logs/ssl.access.log;    </pre>
<pre>error_log /usr/local/nginx/logs/ssl.error.log;</pre>
</td>
</tr></tbody></table>
<p>重启Nginx:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># /usr/local/nginx/sbin/nginx -s reload
</pre>
</td>
</tr></tbody></table>
<p>另外,请参考Nginx SSL文档(<a href="http://wiki.nginx.org/NginxHttpSslModule">http://wiki.nginx.org/NginxHttpSslModule</a>
)。</p>
<p><strong>16、Nginx和PHP安全技巧</strong>
</p>
<p>PHP是流行的服务器端脚本语言,对/etc/php.ini做如下修改:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># 禁用危险的函数</pre>
<pre>disable_functions = phpinfo, system, mail, exec</pre>
<pre>## 限制资源  ##</pre>
<pre># 每个脚本的最大执行时间,单位秒</pre>
<pre>max_execution_time = 30</pre>
<pre># 每个脚本解析请求数据的最大时间</pre>
<pre>max_input_time = 60</pre>
<pre># 每个脚本可以消耗的最大内存(8MB)</pre>
<pre>memory_limit = 8M</pre>
<pre># PHP要接收的POST数据最大大小</pre>
<pre>post_max_size = 8M</pre>
<pre># 是否允许HTTP文件上传</pre>
<pre>file_uploads = Off</pre>
<pre># 允许上传的最大文件大小</pre>
<pre>upload_max_filesize = 2M</pre>
<pre># 不将PHP错误消息暴露给外部用户</pre>
<pre>display_errors = Off</pre>
<pre># 启用安全模式</pre>
<pre>safe_mode = On</pre>
<pre># 只允许访问隔离目录中的可执行文件</pre>
<pre>safe_mode_exec_dir = php-required-executables-path</pre>
<pre># 限制外部访问PHP资源</pre>
<pre>safe_mode_allowed_env_vars = PHP_</pre>
<pre># 限制泄露PHP信息</pre>
<pre>expose_php = Off</pre>
<pre># 记录所有错误</pre>
<pre>log_errors = On</pre>
<pre># 不为输入数据注册全局</pre>
<pre>register_globals = Off</pre>
<pre># 最小化允许的php post大小</pre>
<pre>post_max_size = 1K</pre>
<pre># 确保PHP重定向正确</pre>
<pre>cgi.force_redirect = 0</pre>
<pre># 禁止上传,除非必要</pre>
<pre>file_uploads = Off</pre>
<pre># 启用SQL安全模式</pre>
<pre>sql.safe_mode = On</pre>
<pre># 避免打开远程文件</pre>
<pre>allow_url_fopen = Off</pre>
</td>
</tr></tbody></table>
<p>另外,请参考“PHP安全:限制脚本使用的资源”(<a href="http://www.cyberciti.biz/faq/php-resources-limits/">http://www.cyberciti.biz/faq/php-resources-limits/</a>
),“PHP.INI:禁用exec,shell_exec,system,popen和其它功能提高安全”(<a href="http://www.cyberciti.biz/faq/linux-unix-apache-lighttpd-phpini-disable-functions/">http://www.cyberciti.biz/faq/linux-unix-apache-lighttpd-phpini-disable-functions/</a>
)。</p>
<p><strong>17、尽可能在Chroot Jail(容器)中运行Nginx</strong>
</p>
<p>将Nginx放入Chroot Jail可以最大限度地减少被攻击的危险,它将Web服务器隔离到文件系统的专用区域,注意你不能使用传统的chroot方法设置Nginx,但你可以使用FreeBSD jails,Xen或OpenVZ虚拟化,它们也使用了容器的概念。</p>
<p><strong>18、在防火墙级限制每个IP的连接</strong>
</p>
<p>Web服务器必须时刻关注连接和每秒的连接限制,pf和iptables都可以在访问Nginx服务器之前卡住最终用户。</p>
<p>Linux iptables:每秒卡住的Nginx连接</p>
<p>下面的例子表示如果某个IP在60秒尝试连接到80端口的次数超过了15,iptables将会丢掉来自它的入站连接:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>/sbin/iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set</pre>
<pre>/sbin/iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent </pre>
<pre>--update --seconds 60  --hitcount 15 -j DROP</pre>
<pre>service iptables save</pre>
</td>
</tr></tbody></table>
<p>BSD PF:每秒卡住的Nginx连接</p>
<p>编辑/etc/pf.conf,做如下更新,下面的命令限制了每个来源的最大连接数为100,15/5指定某时间跨度内的连接数限制,这里就是5秒内的最大连接数为</p>
<p>15,如果有人违背这条规则,将被加入到abusive_ips表,那么他以后就不能再连接了。最后刷新所有状态。</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>ebserver_ip="202.54.1.1"</pre>
<pre>table  persist</pre>
<pre>block in quick from </pre>
<pre>pass in on $ext_if proto tcp to $webserver_ip port www flags S/SA keep state (max-src-conn 100, </pre>
<pre>max-src-conn-rate 15/5, overload  flush)</pre>
</td>
</tr></tbody></table>
<p>请根据你的需要和通信流量调整所有的值(浏览器可能会打开多个连接)。</p>
<p>另外,请参考“PF防火墙脚本示例”(<a href="http://bash.cyberciti.biz/firewall/pf-firewall-script/">http://bash.cyberciti.biz/firewall/pf-firewall-script/</a>
),“iptables防火墙脚本示例”(<a href="http://bash.cyberciti.biz/firewall/linux-iptables-firewall-shell-script-for-standalone-server/">http://bash.cyberciti.biz/firewall/linux-iptables-firewall-shell-script-for-standalone-server/</a>
)。</p>
<p><strong>19、配置操作系统保护Web服务器</strong>
</p>
<p>除了开启SELinux外,还要给/nginx目录设置正确的权限,运行Nginx的系统用户名是nginx,但在DocumentRoot(/nginx或/usr/local/nginx/html)中的文件不应该</p>
<p>属于该用户,他也不能进行修改。使用下面的命令找出权限设置不当的文件:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># find /nginx -user nginx</pre>
<pre># find /usr/local/nginx/html -user nginx</pre>
</td>
</tr></tbody></table>
<p>请确保将文件的所有者修改为root或其它用户,一个典型的权限设置如下:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># ls -l /usr/local/nginx/html/
</pre>
</td>
</tr></tbody></table>
<p>输出示例:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>-rw-r--r-- 1 root root 925 Jan  3 00:50 error4xx.html</pre>
<pre>-rw-r--r-- 1 root root  52 Jan  3 10:00 error5xx.html</pre>
<pre>-rw-r--r-- 1 root root 134 Jan  3 00:52 index.html</pre>
</td>
</tr></tbody></table>
<p>另外,你必须删除由vi或其它文本编辑器创建的不必要的备份文件:</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># find /nginx -name '.?*' -not -name .ht* -or -name '*~' -or -name '*.bak*' -or -name '*.old*'</pre>
<pre># find /usr/local/nginx/html/ -name '.?*' -not -name .ht* -or -name '*~' </pre>
<pre>-or -name '*.bak*' -or -name '*.old*'</pre>
</td>
</tr></tbody></table>
<p>给find命令传递-delete参数,它就会自动删除这些文件。</p>
<p><strong>20、限制出站Nginx连接</strong>
</p>
<p>攻击者可能要在你的Web服务器上使用如wget等工具下载文件,使用iptables阻止来自Nginx用户的出站连接,ipt_owner模块
可以匹配各种包创建者的特征,只有在OUTPUT链中的才有效,在这里,允许vivek用户使用80端口连接外部资源(对RHN访问或通过仓库抓取
CentOS更新特别有用)。</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre>/sbin/iptables -A OUTPUT -o eth0 -m owner --uid-owner vivek -p tcp </pre>
<pre>--dport 80 -m state --state NEW,ESTABLISHED  -j ACCEPT</pre>
</td>
</tr></tbody></table>
<p>将上述规则添加到你的iptables基础shell脚本中,不允许nginx Web服务器用户连接外部资源。</p>
<p>附送技巧:观察日志和审核</p>
<p>检查日志文件,可以从中找到攻击者的一些行踪和攻击手段。</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="400" align="center"><tbody><tr>
<td class="code">
<pre># grep "/login.php??" /usr/local/nginx/logs/access_log</pre>
<pre># grep "...etc/passwd" /usr/local/nginx/logs/access_log</pre>
<pre># egrep -i "denied|error|warn" /usr/local/nginx/logs/error_log</pre>
</td>
</tr></tbody></table>
<p>Auditd服务提供了系统审核功能,启动SELinux事件,认证事件,文件修改,帐户修改等的审核服务,象往常一样首先关闭所有服务,然后打开我在“Linux服务器加固”(<a href="http://www.cyberciti.biz/tips/linux-security.html">http://www.cyberciti.biz/tips/linux-security.html</a>
)一文中指出的服务。</p>
<p><strong>总结</strong>
</p>
<p>通过这些设置,你的Nginx服务器就可以对外提供服务了,但你应该根据应用程序安全需要进一步查看另外的资源。例如,WordPress或其它第三方程序都有其自身的安全要求。</p>
分享到:
评论

相关推荐

    Nginx高性能WEB服务器最佳实践.pdf

    Nginx高性能WEB服务器最佳实践,linux的基础知识,有需要的可以看一下

    OpenResty开发最佳实践pdf

    通过揉和众多设计良好的 Nginx 模块,OpenResty 有效地把 Nginx 服务器转变为一个强大的 Web 应用服务器,基于它开发人员可以使用 Lua 编程语言对 Nginx 核心以及现有的各种 Nginx C 模块进行脚本编程,构建出可以...

    OpenResty最佳实践

    通过揉和众多设计良好的 nginx 模块,OpenResty 有效地把 nginx 服务器转变为一个强大的 Web 应用服务器,基于它开发人员可以使用 lua 编程语言对 nginx 核心以及现有的各种 nginx C 模块进行脚本编程,构建出可以...

    nginx-basics:Nginx基础

    该演示需要NGINX演示的四个docker容器:NGINX Plus ADC /负载均衡器, nginx-plus,和Web服务器, nginx1 , nginx2和nginx3 : 附加容器用于实验室指南,可在端口9000上使用 容器的详细信息: 基于ubuntu 18.04的...

    openresty最佳实践

    OpenResty 是一个强大的 Web 应用服务器,Web 开发人员可以使用 Lua 脚本语言调动 Nginx 支持的各种 C 以及 Lua 模块,更主要的是在性能方面,OpenResty可以 快速构造出足以胜任 10K 以上并发连接响应的超高性能 Web ...

    Magento2x-OSX-Nginx:如何安装Magento 2x Mac或OSX,Nginx,MySQL,PHP(MEMP堆栈)

    OSX-Nginx 如何安装Magento 2x Mac或OSX,Nginx,MySQL,PHP(MEMP堆栈) 我的开发环境: Magento 2.3.x nginx/1.14.x PHP 7.2.x MySQL 5.7 macOS/OSX :10.13.6我将向所有人展示最佳实践,即如何使用Nginx在OSX上...

    quickstart-nginx-plus:AWS快速入门团队

    NGINX Plus是基于NGINX构建的应用程序交付平台,NGINX是一个开放源Web服务器和高流量站点的反向代理。 NGINX Plus增加了技术支持和企业就绪功能,用于高级负载平衡,Web和移动加速,应用程序安全性,监视和管理 ...

    zabbix5forcentos7:Ansible,zabbix 5.0和CentOS7的很少实践(当然不是最佳实践)

    zabbix5forcentos7 这是在Posgresql DB和Nginx Web服务器上在Centos 7上安装Zabbix 5的小项目。所有配置文件都放在./roles/zabbix5{agent|server}中,默认情况下使用localhost的设置(对于zabbix DB具有非常简单的...

    shcms:一个基于laravel的cms系统

    [项目关闭,不再维护]shcms一个基于laravel5.4最佳实践的cms程序,使用多个现代web开发特性。在线演示特色全文搜索权限管理云平台友好非常多精致优雅的小细节运行环境PHP5.5及以上,推荐使用PHP7.1 nginx或其他Web...

    javasnmp源码-awesome-stars::sparkles::sparkles:我自己的真棒清单!

    最佳实践的工作示例 批处理文件 - 为人类编写的 Python 最佳实践指南。 C - 如何从头开始创建操作系统 - 在 Web 浏览器中可视化 Python、Java、JavaScript、TypeScript、Ruby、C 和 C++ 代码执行 - 具有文件加密和...

    terraform-aws-tech-test:AWS和Terraform技术测试

    目前,我们只有一个实例以默认配置运行Web服务器Nginx,并提供默认的欢迎页面。 要运行terraform,请使用以下命令: terraform apply -var-file=dublin.tfvars 完成所有练习,确保正确使用git。 随意修改和重构...

    网络架构师148讲视频课程

    │ 第128节:应用建议及最佳实践.avi │ 第129节:MongoDB结合应用开发一.avi │ 第130节:MongoDB结合应用开发二.avi │ 第131节:应用MongoDB后体系结构.avi │ 第132节:MogileFS简介和入门.avi │ 第133节:...

Global site tag (gtag.js) - Google Analytics