Articles of nginx

如何刷新Nginx的SSLcaching服务器推送的中间请求

我正在写一个应用程序,使用长轮询将消息推送到客户端。 当它完成发送消息时,它不会结束请求:它只是刷新。 它工作正常,即使我通过nginx代理并通过互联网访问它。 upstream app { server localhost:1000; } server { listen 80; location / { proxy_pass http://app; client_max_body_size 20m; proxy_redirect off; send_timeout 86400; proxy_read_timeout 86400; proxy_buffering off; gzip off; } } 也就是说,直到我在nginx上启用SSL。 那么它不会再冲洗了。 我可以通过将ssl_buffer_size设置为1来解决这个问题,但是这会对性能产生负面影响。 server { listen 443; ssl_certificate cert.pem; ssl_certificate_key key.pem; ssl_buffer_size 1; … } 有了其他的缓冲区大小,除非请求结束,否则NginX不会刷新最后一个不完整的缓冲区。 有什么办法强制它? 我想要这个愚蠢吗? 我已经注意到,只要数据量低于61450字节,刷新就可以工作。 如果你尝试冲洗更多,它开始缓冲。

Nginx + PHP-FPM客户端中止

这是我的configuration(Nginx 1.7.x): server { listen 8000; index index.php index.html index.htm; root /var/www/; server_tokens off; chunked_transfer_encoding off; location ~ \.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; fastcgi_keep_conn on; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } } 和php-fpmconfiguration: [www] user = www-data group = www-data listen = /var/run/php5-fpm.sock listen.owner = www-data listen.group = […]

504网关超时/ 502安装php curl – server nginx后网关不好

我有(好)一个有nginx的工作服务器在船上。 一个服务器(专用)仅用于托pipe一个drupal站点。 最近我们决定在这个店铺上一个magento商店,并开始准备。 由于magento和nginx不能一起工作,我们不得不将nginx升级到最新版本。 一切似乎都很好。 昨天我已经安装了php5-curl(这是由magento reguired)和..事情变糟糕。 (尽pipe在curl.ini中注释掉一行并不能解决任何问题) 每次尝试访问一个PHP网站(Drupal或Mgento或自定义脚本结束于: 504网关超时 所以我已经开始谷歌,从主题的负载,随之而来的一堆build议,但似乎没有任何工作。 当我尝试修改nginx设置(例如添加: location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_read_timeout 300; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_nam$ } 504错误更改为 502错误的网关 和nginx错误日志:504错误: 2014/11/20 13:17:56 [错误] 20800#0:* 27上行超时(110:连接计时结束),从上游读取响应头,client:…,serve r:www。(。 …),请求:“GET(..)/ HTTP / 1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“…” 对于502错误: (…),服务器r:(…),请求:“GET(…)(…) )HTTP / 1.1“,上游:”fa stcgi://127.0.0.1:9000“,主机:”(…)“ additionally netstat shows this: root@ns394907:/etc/nginx# netstat | […]

正确的重写语法来删除index.php

我有一个nginx vHost主机: CMS在/ 在/store一个magento /store 事情运行良好,除了一件事情: 从URL中删除index.php。 目前下面的URL正在工作 example.com/store/index.php/my-funny-test-product.html and (as there are a few subshops in magento) example.com/store/index.php/city/my-funny-test-product.html 现在我必须build立一个redirect,以便index.php可以从URL中删除。 example.com/store/my-funny-test-product.html or example.com/store/city/my-funny-test-product.html 我用这个.htaccess来处理我的本地Apache RewriteEngine on RewriteBase /store/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule .* index.php [L] 基于这个我build立了以下重写 location /store { rewrite ^/store /store/index.php; } 现在example.com/store/my-funny-test-product.html作品,但CSS图像和类似的东西坏了! 我试图添加if (!-e $request_filename)来解决,但得到了一个nginx 40x错误。 我怎样才能实现工作重写example.com/store/my-funny-test-product.html和example.com/store/city/my-funny-test-product.html子文件夹/商店没有打破CSS&有没有index.php在URL中? […]

NGINX:磁盘写入尖峰和/或没有足够的工作人员错误突然激增的stream量导致500错误

我一直在尝试诊断我们在生产服务器上遇到的问题。 我们有一台运行NGINX的服务器作为负载均衡器,负责在四台应用服务器之间拆分请求。 在testing网站的时候,我们每天至less会有几次错误,但是我们得到的错误只能持续几秒钟。 通过错误日志和访问日志,以及新的遗物和我们的托pipe服务的graphics,我已经注意到了一些事情… 每天几次,负载平衡器上的磁盘突然大量跳跃。 我很确定这是由于很短的时间内写入访问日志的请求太多了(昨天已经超过了300MB,其中大部分是在很短的时间内)……几乎如果一堆请求被阻塞,堆积,然后同时吐出。 另外,偶尔我会在错误日志中得到“768工作者连接是不够的…”。 我猜我只需要提高这个限制,但我不知道多less,或者我怎么能find最大的工作。 我不确定这两个问题是否连接在一起,或者如果其中一个导致我们的随机500错误。 任何有关进一步诊断的见解或build议将不胜感激!

nginx使用proxy_pass和$ http + CloudFlareredirect循环

我的nginxconfiguration很好,直到我添加一个强制HTTPS的redirect。 redirect之前的工作configuration是: server { listen 80; listen 443 default_server ssl; server_name my-domain.com www.my-domain.com; client_max_body_size 5M; location / { proxy_pass http://localhost:3000; } } 我在服务器的端口3000上运行一个应用程序,我想在端口80和端口443(http和https)的域中提供它。 不过,我也希望在用户尝试通过HTTP访问时将用户redirect到HTTPS。 我用这个答案来设置: server { listen 80; server_name my-domain.com www.my-domain.com; client_max_body_size 5M; return 301 https://$server_name$request_uri; } server { listen 443 default_server ssl; server_name my-domain.com www.my-domain.com; client_max_body_size 5M; location / { proxy_pass http://localhost:3000; } […]

NVA:在清漆之前或之后重写?

我正在计划一个NVA服务器系统(Nginx-Varnish-Apache),请求按照这个顺序进行路由。 Apache将服务WordPress CMS或类似的。 我想知道在哪里应用额外的重写规则(如添加自定义重写手动configuration)。 应该重写在Nginx端还是Apache端? 哪个更容易实现,哪个更好? 还是应该重写在光油? 正如我所看到的,所有重写都可以在Apache中完成,因为Varnish将按原样提供这些重写的请求,从而在提供页面之前降低处理(?)的需求。 我是对的,还是在请求页面清除(从Apache获取页面)之前重写呢? 这要求服务器实际检查并对每个请求进行重写。 但是这样所有的重写将是“即时的”,而不需要在Varnish清除caching。 例1: 我有一个WordPress的多站点与子域安装(子站点去foo.domain.com , bar.domain.com , baz.domain.com等)。 多站点根站点应该驻留在www.domain.com ,但实际的内容可以在domain.com (不需要www )。 WordPress本身处理子网站的子域映射(数据库表切换),但是无www到www重写应该手动完成。 在哪里重写呢? 例2: 我在后台有一个特定的模板,有时可能会被重写,有时候不会。 让我们说它的www.domain.com/offer/12345/?available=0 ,有时我们可能要重写URLredirect到一个模板www.domain.com/offers有关不可用的数据。 这个重写会来来去去,取决于网站是否有不可用的报价情况的内容。 在Varnish之前或之后,这种重写会更好吗? (我知道这个redirect应该在网站的内部逻辑中完成以实现自动化,但是为了这个例子,我们假设它应该被服务器自己重写)。

Haproxy:对静态内容的响应缓慢

我们正在使用HAProxy进行负载均衡。 我们的应用程序运行在10个Caucho Resin服务器和7个专用的Nginx服务器(用于静态内容)。 版本: HA-Proxy version 1.5-dev19 2013/06/17 nginx version: nginx/1.4.6 (Ubuntu) 我现在的问题是JS,CSS和图像文件等静态内容的超慢响应。 当我通过HAproxy来curl或者查看一些文件时,响应时间太高了,大约3秒或者更长,但是如果我这样做的话,直接从Nginx服务器获取响应的时间大约是300ms到600ms,反而更好。 我用ab完成了一个小testing,使用了10个并发的连接。 通过HAProxy: Connection Times (ms) min mean[+/-sd] median max Connect: 336 340 2.7 341 343 Processing: 425 779 738.3 471 2687 Waiting: 209 459 710.0 241 2479 Total: 760 1119 739.7 812 3030 Percentage of the requests served within a certain […]

Ubuntu升级PHP不工作了,也没有错误日志

我运行apt-get update ,然后在我的Ubuntu(Homestead VM)上进行apt-get upgrade 。 从那时起,我无法访问我的PHP应用程序了。 我试图从我的应用程序访问一个txt文件,这个工程(http //…../ test.txt),但是当试图访问一个PHP文件,我得到一个空白的屏幕。 testingphp文件的内容是 <?php echo phpinfo(); 我不太确定在哪里看,因为我找不到任何错误消息。 我到现在为止所做的: find使用的PHP.INI:find使用的PHP.INI: php -i | grep 'php.ini' php -i | grep 'php.ini' 编辑PHP.INI以显示错误: display_errors = On display_startup_errors =开 log_errors =开 检查nginxconfiguration/etc/nginx/sites-enabled/mysite.conf server { listen 80; server_name mysite.dev; root /home/vagrant/mysite.com/www/mysite.com/public; index index.html index.htm index.php; charset utf-8; location / { try_files $uri […]

Nginx虚拟主机403禁止

我刚刚带了一个域名(example.com),并设置了一个URL框架redirect到我的服务器的IP XXX.XXX.XXX.XXX,但是我得到一个403禁止的错误。 我可以通过服务器IP访问页面。 我想要的是复制的服务器IP使用我的域的行为,所以我试图复制我的IP虚拟主机,但它不工作。 这是我的虚拟主机文件: server { listen 80; server_name example.com ; access_log /var/log/nginx/website.access_log; error_log /var/log/nginx/website.error_log; root /var/www; index index.html; location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/phpMyAdmin; include fastcgi_params; } } 而我目前用IP直接访问服务器(工作): server { listen 80; server_name xxx.xxx.xxx.xxx ; access_log /var/log/nginx/website.access_log; error_log /var/log/nginx/website.error_log; root /var/www; index index.php; location […]