Articles of nginx

Nginx位置匹配查询参数

是否有可能在nginx有一个location {…}块匹配查询参数。 例如,我想在下面的URL中select该preview=true ,然后指示它在位置块中执行几个不同的操作。 http://192.158.0.1/web/test.php?hello=test&preview=true&another=var 我遇到的问题是,我的testing的东西似乎不匹配,似乎我只能匹配url本身? 例如 location ~ ^(.*)(preview)(.*)$ 还是那些线路上的东西?

php5.4 + freebsd8.3 + nginx无法获取错误

我有一个混乱的行为。 我不能得到任何错误到日志文件或屏幕。 我用这样的内容创build了一个文件index.php:“<?php a();”。通常,我会得到这样的消息:“调用未定义的函数a()”,但是当我在configuration上调用这个脚本时一无所有 只有白色的屏幕和空的日志。 我检查了所有的权利。 我打开了所有可能的日志文件。 没有。 请帮帮我。 我的configuration是: freebsd 8.3-RELEASE PHP 5.4.7(fpm-fcgi) nginx版本:nginx / 1.2.4 FPM-configuration [global] pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice emergency_restart_threshold = 5 emergency_restart_interval = 2 process_control_timeout = 2 daemonize = yes events.mechanism = kqueue [puser] listen = /usr/local/www/host/tmp/php-fpm.sock; listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = […]

Nginx + Haproxy + Thin + Rails – 503服务不可用 –

我不知道如何解决这个问题。 我得到“503服务不可用”http错误所有“nginx上游”代理传递调用haproxy fast_thin和slow_thin(服务器127.0.0.1:3100和服务器127.0.0.1:3200),负载均衡6瘦服务器(127.0.0.1: 3000 .. 3005)。 像/博客等静态文件目前很好。 falldown是:在端口80上的nginx – 在3100和3200上的haproxy – 在3000 .. 3005上再单击Rails。 这里是/etc/nginx/nginx.conf: user nginx; worker_processes 2; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; sendfile on; tcp_nopush on; keepalive_timeout 65; tcp_nodelay on; include […]

在nginx中使用$ limit_rate时出现错误404

我有这个configuration在nginx上运行 root@homer:/home/admin# cat /etc/nginx/sites-enabled/example.com server { listen 80; server_name www.example.com example.com; access_log /var/www/example.com/logs/access.log; error_log /var/www/example.com/logs/error.log; ## Only allow these request methods (do not accept DELETE, SEARCH and others.. ## if ($request_method !~ ^(GET|HEAD|POST)$ ) {return 444; } location / { root /var/www/example.com/public_html; index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; if ($uri […]

通过加载web服务器访问日志来实时监控Web服务器日志

我正在寻找一种方法来find谁在我的nginx Web服务器上造成高负载,但我确实有太多请求每分钟弄清楚哪一个是真正的原因。 我想要一个解决scheme可以像top一样工作,但是这会让我开始像 ip | requests | average response time | total response time —|———–|———————–|——————– 每行看起来像: 10.80.3.169 – – [02/Nov/2012:12:15:37 +0000] "POST /pages/docreatepage.action HTTP/1.1" 302 0 "http://example.com/pages/docreate" "Mozilla…" "-" 1.074 1.074 所以我需要每行的forms是第一部分(IP)和最后一部分(持续时间),并计数它们,并显示每隔几秒钟开始。 有没有一个工具可以做到这一点,或者我必须自己编写代码?

使用HAProxy或Nginx在VPS之间加载平衡

我想负载平衡+故障转移备份多个vpsnetworking服务器托pipe在不同的供应商。 我听说HAProxy需要在同一个子网下有多台服务器,再加上负载均衡器之间的共享(虚拟)IP地址。 但在我的情况下是不可能的,因为每个VPS都在不同的节点/networking上。 有没有办法在这种设置中使用HAProxy? ( 请解释一下,我不想听到你的“是”的答案 ) 那么NginX呢? 是否有可能达到与Nginx相同的结果? (当服务器位于不同的networking上时) 我知道Round Rubin DNS,但是它不提供真正的故障转移解决scheme,既不是服务器之间的负载平衡。

如何确认Nginx高速caching代理的工作

我有端口80上的nginx和端口8080上的apache在同一台服务器上。 我已经configurationnginx,使其作为反向代理(我不知道它的工作与否)使用本教程htt://tumblr.intranation.com/post/766288369/using-nginx-reverse-proxy。 我遵循的步骤来validation代理。 在5秒的时间间隔内在两台不同的机器上打开相同的页面。 但在Apache的access.log每个请求显示200响应代码。是否表明caching不工作? 而nginx access.log没有显示任何内容。

Nginx + WordPress的permisions设置

我正在用nginx支持的wordpress安装来试验一些麻烦。 该架构在亚马逊举行,是以下内容: EC2 Nginx 1.2.4 + php-fpm服务器EC2 NFS服务器RDS mysql nginx从/ mnt / sharedpool / blog的nfs分区读取站点文件 fstabconfiguration是: compute-1.amazonaws.com:/mnt/sharedpool/mnt/publicpool nfs rw,relatime 0 0 nfs服务器/ etc / exportsconfiguration: / mnt / sharedpool ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com(rw,sync) nginx用户和组设置为www-data:www-data,站点的根指令设置为/ mnt / sharedpool / blog 我下载了wordpress的最新版本,并成功安装了它。 事情是,login后,我得到403禁止..我认为应该是一个WordPress的设置,因为我可以在同一个目录中创build和调用一个phpinfo()。 更新: Nginx服务器configuration: 用户www-data www-data; worker_processes 1; pid /var/run/nginx.pid; 事件{worker_connections 768; #multi_accept on; } http { ## # […]

Nginx将https的某个页面redirect到http

如何将特定的https页面redirect到http,例如: https://example.com/foo – > http://example.com/foo 只为页面foo,没有其他页面。 谢谢。

如何将nginx的用户代理列入白名单?

我想弄清楚如何将我的nginx conf中的用户代理列入白名单。 所有其他代理应显示密码提示。 在我的天真中,我试图把以下内容deny all : if ($http_user_agent ~* SpecialAgent ) { allow; } 但是我被告知"allow" directive is not allowed here (!)。 我怎样才能使它工作? 我的configuration文件的一大块: server { server_name site.com; root /var/www/site; auth_basic "Restricted"; auth_basic_user_file /usr/local/nginx/conf/htpasswd; allow 123.456.789.123; deny all; satisfy any; #other stuff… } 谢谢你的帮助。