Articles of nginx

负载平衡定期挂起(但后端工作正常),如计划

有Debian Squeeze服务器: 1)Load Balancer – Hyproxy 1.4.18,16个cpu核心,5-10 GB RAM(这是云服务) 2)4个Apache后端(10 GB RAM,16个cpu内核) 当我们开始haproxy时,网站运行良好约2分钟,然后约30秒钟挂起。 (此时直接访问后台运行良好,没有缓慢的数据库查询或任何后端问题)在这种情况重复之后。 有趣的观察:我们试图使用nginx作为平衡器,我们得到了同样的行为。 当haproxy(nginx)挂起时,没有任何cpu或ram高负载。 什么可能是这种行为的原因? 谢谢!

在Nginx 0.8.54-4中用try_files清理我的configuration

遵循陷阱指南后,我正在尝试使用try_files指令清理我的URL重写。 但是,当我在安装Nginx 0.8.54-4(来自dotdeb)时使用这个命令时,当试图访问该站点(其中包含index.php PHP脚本的源代码)时,会提示下载BIN文件。 那么,这些指令是否与我的nginx版本不兼容,或者这个vhost有什么问题? server { listen 80; server_name site.loc; root /home/user/www/site.loc/docroot; index index.html index.php; location / { try_files $uri $uri/ @runphp; } # Pass all .php files to PHP-FastCGI location @runphp { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } } 另外,这是甚至是这样做的最好方法吗? 我的原始(工作)configuration看起来像这样: server { listen 80; server_name site.loc; root /home/user/www/site.loc/docroot; index index.html […]

Nginx:closuresgzip到PDF文件

我正在使用这个代码来通过PHP提供下载文件: $file='file.pdf'; $filepath="/path-to-download-folder/$file"; if(!file_exists($filepath)){ header('HTTP/1.1 404 Not Found'); exit; }elseif(!is_file($filepath) or !is_readable($filepath)){ header('HTTP/1.1 403 Forbidden'); exit; }else{ header('Cache-Control: no-store, no-cache, must-revalidate'); header('Content-Type: '.mime_content_type($filepath)); header('Content-Length: '.filesize($filepath)); header('Content-Disposition: attachment; filename="'.$file.'"'); set_time_limit(0); // Big files/slow connections may result in incomplete downloads readfile($filepath); exit; } 但是有些人正在收到一个损坏的PDF文件。 例如: http : //mlkshk.com/r/8FGS 在Nginx中我有这样的: gzip on; gzip_disable "msie6"; # gzip_vary on; # […]

Nginx的外部POST返回302

我有一个使用Nginx 1.1.4 + PHP-FPM + APC的服务器设置。 在此服务器上运行Magento 1.5.1.0安装。 我遇到的麻烦是来自支付提供者的callback是一个POST,Nginx返回一个302,这使得callback失败。 这是Nginx网站的configuration文件: server { listen 80; server_name <domain>; root <path to root>; if ($host ~* ^([a-z0-9\-]+\.(com|net|org))$) { set $host_with_www www.$1; rewrite ^(.*)$ http://$host_with_www$1 permanent; } location / { index index.html index.php; try_files $uri $uri/ @handler; expires 30d; } location /nginx_status { stub_status on; access_log off; #allow 127.0.0.1; […]

使用ssl将www添加到非www地址

我希望没有www的所有stream量(包括https)被redirect到www的相应url。 所以http://example.com – > http://www.example.com,https : //example.com – > https://www.example.com 网上有很多关于强制ssl的信息,我不想这样做,强制www,但只限于http。 只需要添加一个s并且改变listen 80 – > listen 443就可以打破http网站。 这是我的configuration到目前为止: server { listen 80; server_name example.com; location / { rewrite ^/(.*)$ http://www.example.com/$1 permanent; } } server { listen 80; server_name www.example.com; root /opt/example; index index.html; <locations stuff> } server { listen 443; server_name example.com; ssl on; ssl_certificate […]

Nginx:通配符dns将URLredirect到子域名

我正在尝试redirect以下url Http://example.com/category/something redirect到 Http://something.example.com/category/something “什么”可以是任何东西。 我已经为通配符设置了nginx和Dns,并确认了这一点。

在Nginx后面部署Python?

在Nginx背后部署Python(包括Django)的最佳方法是什么?

Nginx服务了很多写连接?

我的iostat在任何时候都显示接近%util,所以我看着nginx连接报告,看到了 Active connections: 2856 server accepts handled requests 1200179 1200179 1196926 Reading: 6 Writing: 2850 Waiting: 0 我的网站不应该有这么多的写连接,有没有办法看看他们是什么?

添加caching位置块时,nginx proxypass内容404s

我的Nginxconfiguration的位置块添加expires max内容是导致/internal代理网站的内容的问题。 注释expires max位置块允许代理站点按预期工作。 Nginx错误日志 2011/11/22 15:51:23 [error] 22124#0: *2 open() "/var/www/internal/static/javascripts/lib.js" failed (2: No such file or directory), client: 127.0.0.1, server: example.com, request: "GET /internal/static/javascripts/lib.js?0.6.11RC1 HTTP/1.1", host: "example.com", referrer: "https://example.com/internal/" 浏览器错误 lib.js Failed to load resource: the server responded with a status of 404 (Not Found) proxy.conf location /internal { proxy_pass http://localhost:10001/internal/; include proxy.inc; […]

nginx:排除子文件夹被SSLencryption

我已经把我的服务器设置为像我这样的nginx服务器: server { listen 443; ssl on; ssl_certificate /etc/ssl/certs/example.com.crt; ssl_certificate_key /etc/ssl/private/example.com.key; server_name example.com; … other things down here.. } 我如何从SSL中排除目录? 例如,在/静态/游览我有一个解释的Web应用程序,并没有必要encryption。 操作系统:Ubuntu 10.04