浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

好文

 

server_tokens 指令指定 nginx 在应答报文 header 和默认错误页面中是否显示版本号等具体信息。生产环境中应尽量避免透露过多的服务器信息,因此,必须设置为 off。类似的还有 php 页面,在配置文件中必须指定 fastcgi_hide_header X-Powered-By; 避免在应答报文 header 中透露服务器当前使用的 php 版本号。 

  

Nginx 监听非80端口,进行目录后缀“/”补全时,返回的 Location 值中的URL带了端口号。此操作逻辑是正确的,但是与我们生产环境有冲突。生产环境中,请求通过前端 alteon 设备重定向至后端的8080、9090端口,这些端口并不对外,因此就会出现重定向的地址无法访问的情况。需要在所有虚拟主机配置中通过配置 rewrite 来避免这种情况:rewrite ^/([^.]+[^/])$ http://$host/$1/ permanent; 

 

l 为保证生产系统的稳定运行,nginx 与 php-cgi 的通讯端口请使用 tcp/ip 方式,而不使用 unix 套接字。虽然tcp/ip效率较低,但是相对稳定,而且可以将php运行在其他机器上。当 php 应用运行较慢,并发请求多的情况下,使用 unix 套接字容易导致连接失败,从而报告 502 错误(Bad Gateway)。 

 

 

http://hi.baidu.com/ncache/blog/item/ee660f766755c213b151b959.html

 

   server {
      <span class="search_hit">listen</span>  80;  # port and optionally hostname where <span class="search_hit">nginx</span> <span class="search_hit">listen</span> http requests, change to appropriated values!
      server_name  example.com translate.example.com; # names of your site, change to appropriated values!

      location = / {
              proxy_pass   http://localhost:<span class="search_hit">8080</span>/;  # assumed your PootleServer <span class="search_hit">listen</span> <span class="search_hit">8080</span> port on localhost
              proxy_set_header  X-Real-IP  $remote_addr;
      }

      location ^~ /images/ {
              root /usr/lib/python2.3/site-packages/Pootle/html/;
      }

      location ~* \.css {
                      root /usr/lib/python2.3/site-packages/Pootle/html/;
      }

      location ^~ /js/ {
                      root /usr/lib/python2.3/site-packages/Pootle/html/;
      }

      location ^~ /doc/ {
              root /usr/lib/python2.3/site-packages/Pootle/html/;
      }

      location / {
              proxy_pass   http://localhost:<span class="search_hit">8080</span>/;
              proxy_set_header  X-Real-IP  $remote_addr;
      }

      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   /usr/local/<span class="search_hit">nginx</span>/html;  # assumed your <span class="search_hit">Nginx</span> installed in /usr/local, change to appropriated value!
      }

  }
reference:
http://translate.sourceforge.net/wiki/pootle/nginx<br />
<br />

 

 

 

 

 

 

Static Content
Serving static files from htdocs dir ala /<site>/chrome/site aliases http://live.trachosts.com/myproj/chrome/site to /var/trachosts/trac/myproj/htdocs

        location ~ /(.*?)/chrome/site/ {
                rewrite /(.*?)/chrome/site/(.*) /$1/htdocs/$2 break;
                root    /var/trachosts/trac;
        }
http://trac.edgewall.org/wiki/TracNginxRecipe<br />
<h3><a href="http://www.thaught.cn/read.php/199.htm">nginx下处理301重定向</a></h3>

 

posted on 2010-09-14 07:01  lexus  阅读(272)  评论(0编辑  收藏  举报