server
{
listen 80;
server_name www.test.com;
if ($host !='www.test.com')
{
rewrite ^/(.*)$ http://www.test.com/$1 permanent;
}
index index.html index.htm index.php;
root /data/www;
location ~ .*admin\.php$ {
auth_basic "wyclinux auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
# /usr/local/nginx/sbin/nginx –t
# /etc/init.d/nginx reload //重新加载nginx
转载于:https://my.oschina.net/vpirate/blog/651413
本文深入剖析了一段复杂的Nginx配置代码,旨在通过实施安全策略和优化配置,提升网站性能和安全性。具体探讨了如何使用Nginx的rewrite指令、基本认证和FastCGI参数,实现对敏感资源的访问控制和内容缓存。通过实例展示,读者将了解如何在实际应用中部署这些技术,以确保网站在面对高并发和安全挑战时保持稳定运行。

2297

被折叠的 条评论
为什么被折叠?



