码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 各种配置

时间:2016-04-11 22:39:19      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

first : mkdir /usr/local/nginx/conf/vhosts
{网站配置}/usr/local/nginx/conf/vhosts/test.conf : server { listen
80; #跳转 server_name www.test.com www.aaa.com www.bbb.com; #全局访问限制 #deny 127.0.0.1; #deny 1.1.1.1; #跳转 if ($host != www.test.com) { rewrite ^/(.*)$ http://www.test.com/$1 permanent; } index index.html index.htm index.php; root /data/www; #记录登陆的日志 access_log /tmp/access.log ff; #禁止指定user_agent if ($http_user_agent ~ baidu|1111) { return 403; } #日志加上防盗链加上静态缓存 location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls)$ { expires 30d; valid_referers none blocked server_names *.test.com *.aaa.com *.aminglinux.com; if ($invalid_referer) { # return 403; rewrite ^/ http://www.example.com/nophoto.gif; } #日志不记录 access_log off; } #对论坛所有php的基本设置 #location ~ \.php$ #对论坛admin.php的设置 location ~ .*admin\.php$ { #全局访问限制 allow 127.0.0.1; deny all; include fastcgi_params; #fastcgi_pass unix:/tmp/php-fcgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name; } } {代理}proxy.conf: upstream ff{ server 61.135.169.125:80; server 61.135.169.121:80 ; } server { listen 80; server_name www.baidu.com; location / { proxy_pass http://ff/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } # access_log /tmp/logs/access.log combined; }
{虚拟主机}default.conf
server
{
  listen 80 defaults_server;
  server_name 111.com;
  root /tmp/tmp;
}

after save : mkdir /tmp/tmp

 

nginx 各种配置

标签:

原文地址:http://www.cnblogs.com/frankielf0921/p/5380172.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!