Articles of nginx

大量低开销请求

我有一个应用程序将处理通过不同的互联网硬件设备发送的大量,低开销请求来接收数据。 随着越来越多的设备被添加到系统中,这些数据将被不断地接收,并且将来只会增加。 一旦接收到数据,经过一些小的处理,它将被插入到数据库(MySQL)中。 我的问题是,我应该使用什么样的服务器软件? node.js是在给定的硬件约束下处理这种请求的最大数量的最佳候选者,还是nginx对于这样的应用程序更好? 还有处理这种请求的最佳做法吗? 例如,我读了如果使用node.js,我可能不得不看看操作系统的ulimit ,以确保在大量的并发请求的情况下,可以创build足够的文件… 谢谢。

从Apache转移到nginx后,在站点地图中的<head />

我有一个名为http://www.domain.com/sitemap1.php的网站地图。 它从这个代码开始: <?php echo '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.weddingpages.nl/sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> '; 从Apache转移到Nginx后,Google网站pipe理员工具开始拒绝我的站点地图告诉我他们看起来像HTML页面。 看着输出,我看到一些奇怪的东西。 使用Nginx: <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.weddingpages.nl/sitemap.xsl"?><head/><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 使用Apache: <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.weddingpages.nl/sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 由于某种原因,我不明白Nginx的投入 <head/> 在urlset之前。 有人知道这个的原因吗? 恐怕这是导致问题的原因。 但即使search,我没有find答案。

如何使用NGINX作为传统(Apache)Web服务器的前端

我有一个已经托pipe两个应用程序的NGINX服务器设置,并在该NGINX服务器上设置了SSL。 现在,我需要将NGINX服务器设置为传统Apache应用程序的前端,以便传统应用程序提供的服务可以通过SSL / HTTPS访问。 如何将我的NGINX服务器configuration为传统应用程序的“传递”服务器?

错误代码:ERR_SPDY_PROTOCOL_ERROR

刚刚在我的debian wheezy,nginx 1.6服务器上安装了StartSSL证书。 一切似乎工作正常,我可以在https浏览网站没有问题,直到我尝试login… IE工作正常,我可以login到OK。 铬给我这个错误:错误代码:ERR_SPDY_PROTOCOL_ERROR Firefox只是挂起,什么都不做。 当我取消StartSSL证书并使用自签名证书时,再次正常工作,我可以login没有任何问题。 我的nginxconfiguration: server { listen 443 ssl spdy; server_name test.com; root /home/www/test.com/; ssl on; ssl_certificate /etc/nginx/certs/test.com.crt; ssl_certificate_key /etc/nginx/certs/test.com.key; access_log /logs/access.log; error_log /logs/error.log; error_page 404 /404.html; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } ………. ……… } 任何build议可能是错误的?

nginx重启单个主机而不影响其他

我的nginx.conf有两个不同的服务器块,一个指向主站点,另一个指向我的api服务器。 现在,无论何时我将其中的一个部署到某个服务器,并停止服务器,它都会停止这两个服务器。 有没有办法停止/重新启动一个特定的服务器,而不打扰另一个? =============编辑: 我一直在做错了。 我不应该重新启动nginx。 在我的情况下,我想要的是乘客识别我的代码更改和刷新。 简单地在Rails.root目录下创build一个tmp/restart.txt Rails.root文件对我来说是个窍门。 对于任何面临相同问题的人,在根path中创build一个空文件tmp/restart.txt restart.txt,每次你想要简单的触摸它。 touch tmp/restart.txt 有关更多详细信息,请查看https://stackoverflow.com/questions/4480078/how-to-make-nginx-be-aware-of-rails-code-changes

Nginx不通过HTTPS提供静态文件

我正在尝试在Apache之前设置Nginx作为反向代理并提供静态文件。 我301 http到https,并提供https部分中的指令通过别名提供静态文件夹。 但是,由于一些奇怪的原因,文件通过http服务。 这是我的Nginx站点configuration: server { listen 80; listen [::]:80; access_log off; server_name site.com www.site.com; return 301 https://$server_name$request_uri; } server { listen 443; ssl on; ssl_certificate /usr/local/sslcert/my.crt; ssl_certificate_key /usr/local/sslcert/my.key; access_log off; server_name site.com www.site.com; location /public/ { alias /var/www/public/; expires max; add_header Pragma public; add_header Cache-Control "public"; } location / { root /var/www/; index […]

try_files如何与fast_cgi一起使用?

我是Nginx的新手,看到向导告诉我,如果我这样做: location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; } (来自https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/的简化示例)。 那么我的理解是,如果客户要求: /uploads/myavatar.gif/ascript.php 如果没有findascript.php ,FastCGI将开始检查path以查看某个部分是否实际上匹配一个文件。 这样,假定: /uploads/myavatar.gif 存在是因为某人上传了该文件,该文件将被处理,并在PATH_INFO中包含$ uri的剩余部分。 所以,'/script.php'将是PATH_INFO中的一个'gif文件'的值,或者也许是另一个扩展名的PHP文件。 所以build议的解决scheme不要落在这样的警告之上是使用: location ~ \.php$ { try_files $uri $uri/ =404; fastcgi_pass 127.0.0.1:9000; } 我的理解是, try_files将检查每个备选文件规范和: 最后一个规范必须存在,否则将抛出一个500。 最后一个规范必须是等号前面的错误代码。 最后一个规范必须声明另一个@location(可以是,例如“_pass”。 我认为我的理解,但似乎我不明白它正确的是:文件检查对root指令(即​​try_files工程通过检查最接近的root目录,并附加每个文件的规范)。 所以,我认为是这样的: root /var/nginx/www; #assume this directory exists location ~ \.php$ { try_files $uri $uri/ =404; fastcgi_pass 127.0.0.1:9000; } #each […]

Rails应用程序部署,nginx,独angular兽,capistrano套接字错误

我正在将一个Rails应用程序部署到数字海洋VPS。 我已经按照https://coderwall.com/p/yz8cha 。 所有的事情都做得很好,但是现在浏览器只显示一个空白页面。 Nginx的日志包含: 2014/08/04 03:07:20 [crit] 20550#0: *4 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$ 2014/08/04 03:08:39 [crit] 20550#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$ 2014/08/04 03:08:40 [crit] 20550#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while […]

缓慢加载PHP脚本使Cloudflare阻止连接

我使用php-fpm和nginx,我正在运行一个缓慢的脚本,但是它阻止了所有的Cloudflare连接,很可能是一个php-fpm的问题,但我无法通过Googlefind任何东西。 如果我运行php脚本(sleep(10)),它将阻塞所有其他页面,直到脚本完成。 但是,我直接访问服务器,我不知道这个问题。 有任何想法吗? php-fpmconfiguration: pm = dynamic pm.max_children = 50000 pm.start_servers = 120 pm.min_spare_servers = 90 pm.max_spare_servers = 180 pm.max_requests = 5000 request_slowlog_timeout = 60s slowlog = /var/log/php-fpm/www-slow.log catch_workers_output = yes nginxconfiguration: user nginx; worker_processes 12; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 19000; } worker_rlimit_nofile 20000; http { include /etc/nginx/mime.types; default_type application/octet-stream; […]

Nginx + Apache mod_wsgi,麻烦了解如何configuration服务器

我一直试图在Ubuntu 12.04上设置一个开发环境太久。 我的意图是在后面的生产环境中设置一切,所以我按照这个教程来学习如何将Nginx设置为Apache 2的反向代理。 我一直在寻找,我的问题与这个问题非常相似,但没有给出答案,我不能评论它来增加我的一些研究。 让我们进入文件: Apache和wsgi 首先,我从apt-get安装了mod_wsgi,然后在/ etc / apache2 / sites-available中创build了一个mysite文件: <VirtualHost *:8080> ServerAdmin [email protected] ServerName mysite.dev ErrorLog /path/to/developmentfolder/mysite/logs/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel debug CustomLog /path/to/developmentfolder/mysite/logs/access.log combined WSGIDaemonProcess mysite WSGIProcessGroup mysite WSGIScriptAlias / /path/to/developmentfolder/mysite/apache/django.wsgi <Directory /path/to/developmentfolder/mysite/apache> Order allow,deny Allow from all </Directory> </VirtualHost> […]