1、Nginx支持PHP,启用以行就可以
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
2、Nginx登录认证及访问控制
location /soft/ {
root /home;
index index.php index.html index.htm;
auth_basic "访问需要权限,请输入帐号密码";
auth_basic_user_file /home/soft/.htpasswd;
deny 10.10.0.10; #访问控制
}
设置密码:htpasswd -cbm /home/soft/conf/htpasswd user01 123456
3、Nginx反向代理
location ~\.php$ {
root html;
index index.php index.html index.htm;
proxy_pass http://10.10.0.226;
proxy_set_header X-Real-IP $remote_addr;
}
proxy_set_header X-Real-IP $remote_addr;可以访问的时候记录真实的IP地址,需要在后端web配置文件中修改日志LogFormat "%{X-Real-IP}i
4、负载均衡
upstream webs {
server 10.10.0.226 weight=1;
server 10.10.0.225 weight=1 max_fails=2 fail_timeout=2;
server 127.0.0.1:8080 backup;
}
server {
listen 8080;
server_name localhost;
root /home/xx;
index index.html;
}
本文出自 “ngames” 博客,请务必保留此出处http://ngames.blog.51cto.com/3187187/1650910
原文地址:http://ngames.blog.51cto.com/3187187/1650910