Articles of nginx

nginx SSL错误

当我运行sbin/nginx -t出现以下错误 [emerg]: the "ssl" parameter requires ngx_http_ssl_module in /root/cloudfoundry/.deployments/devbox/deploy/nginx/nginx-0.8.54/conf/nginx.conf:98 configuration file /root/cloudfoundry/.deployments/devbox/deploy/nginx/nginx-0.8.54/conf/nginx.conf test failed

FreeBSD监听队列溢出 – 不能增加最大队列大小

我有一个非常高的FreeBSD Nginx服务器,我开始得到大量的监听队列溢出: [root@svr ~]# netstat -sp tcp | fgrep listen 80361931 listen queue overflows [root@svr ~]# netstat -Lan | grep "*.80" tcp4 192/0/128 *.80 [root@svr ~]# sysctl kern.ipc.somaxconn kern.ipc.somaxconn: 12288 [root@svr ~]# 但是,我似乎无法增加超过128的最大监听队列长度。我增加了kern.ipc.somaxconn,但它并没有改变最大值。 我错过了什么吗? 谢谢!

nginx条件Accept头

某些移动设备向我们的服务器发送以下不正确的请求: GET / HTTP/1.0 Accept: User-Agent : xxx 空的Accept标头会导致我们的Ruby on Rails服务器返回一个500错误。 在Apache中,以下指令允许我们在将头发送到应用程序RoR服务器之前重写头文件,以便处理破碎的设备: RequestHeader edit Accept ^$ "*/*" early 我们目前正在设置nginx,但是实现相同的解决scheme却很困难。 我们可以设置: proxy_set_header Accept */*; 但是,这似乎必须无条件地完成。 每当试图做: if ($http_accept !~ ".") { proxy_set_header Accept */*; } 它抱怨的消息: "proxy_set_header" directive is not allowed here 因此,使用nginx,在将请求发送到应用程序服务器之前,如何将HTTP Accept头设置为空时设置为*/* ?

如何在nginx中使用HttpMapModule设置$ https值

我试图在http上下文中添加下面的块来设置基于$http_x_forwarded_proto $https : map $http_x_forwarded_proto $https { default off; https on; } 但configurationtesting失败说: nginx: [emerg] the duplicate "https" variable in /etc/nginx/nginx.conf:36 nginx: configuration file /etc/nginx/nginx.conf test failed

反向代理服务器云架构(AWS + nginx)

目前我使用nginx + fastcgicaching响应。 我正在将我的应用程序迁移到AWS。 我构build了一个水平缩放的方法,但试图确定哪里最好把nginx + fastcgicaching。 我从我自己的研究中发现了一些解决scheme,都有明显的缺点。 使用AWS Elastic Load Balancer来平衡一组Web应用程序。 每个Web应用程序都运行它自己的nginx和Web服务器堆栈。 缺点:每台服务器上的caching需要加热 。 最坏的情况1 / n的命中率。 将nginx + fastcgi放在AWS ELB的前面,这样caching就集中在最高点。 缺点:单点故障 – 如果nginx死亡stream量不通过ELB。 增加了nginx实例。 我将不胜感激任何克服上述缺陷的常见体系结构的build议。

Amazon ELB和Nginx服务器上的多域

我有一个EC2实例运行Nginx的几个域。 我的configuration是这样开始的: server { listen 80; #disable_symlinks off; server_name _; #allow few domains #Adding 'www.' to url in case it doesen't if ($host !~* ^www\.) { rewrite ^(.*)$ http://www.$host$1 permanent; } location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php; } index index.html index.php; } 我不知道在ELB(亚马逊)上使用哪个pingpath,因为如果我尝试HTTP,实例总是失败。 如果我尝试TCP(端口80)ping成功。 我必须使用HTTP,因为我想使用粘性。 有什么build议? 谢谢,丹尼

nginx不logging特定ip地址的请求

我试图不logging从一个特定的IP地址,如下所示的请求: location = / { index index.php; if ( $remote_addr = "spe.ci.fic.ip" ) { access_log off; } } 但它不起作用,为什么?

如何设置Varnish,使其不会caching特定的URL与查询string?

服务器设置:Ubuntu 12.10,Varnish 3.0.2,Nginx 1.3.14,安装WordPress 3.5.1。 我们使用“随机redirect”插件,在http://example.com/?random上显示随机博客文章 我想设置Varnish不caching上面的URL,因为目前“随机”的post不断显示相同的职位。 显示在default.vcl中放置什么内容的特定片段将会非常有帮助。 谢谢。

在您的NGINX服务器中拥有ELB的优势是什么?

我研究了很多亚马逊Web服务的后端设置,特别是Instagram的。 在他们的Instgram工程博客上,他们提到他们如何在他们的三个NGINX服务器前面安装一个Elastic Load Balancer,而这些服务器是运行django / Gunicorn的应用程序服务器的前端,为什么这是缓冲? 如果是这样的话,那么如何将这些NGINX服务器连接到django / gunicorn应用程序服务器呢?

我们可以从nginx的某个位置跳转到另一个位置吗?

我正试图达到这样的事情: location /location1/{ if ($arg_api_key = a_valid_api_key) { proxy_pass http://localhost:8080; } # else jump to location2 } location /location2/{ # a lot of validation code here } 我们如何在nginx中做到这一点? 还是有更好的方法来处理它?