我有一个使用NGINX / PHP-FPM运行CentOS的VPS。 一切工作正常,除了当我添加以下行以启用静态caching内容。 如果我这样做,页面不会加载指定的这些文件来保持caching。 location ~* \.(ico|css|js|gif|jpg|jpeg|png)$ { expires 30d; add_header Vary Accept-Encoding; access_log off; } 这是我的整个服务器{}: server { listen 80; server_name mywebsite.com www.mywebsite.com; #location ~* \.(ico|css|js|gif|jpg|jpeg|png)$ { # expires 30d; # add_header Vary Accept-Encoding; # access_log off; #} location / { if ($http_host ~* "^www.(.*)$"){ set $rule_0 1$rule_0; set $bref_1 $1; } if […]
在nginx文档中有一个split_clients指令的例子: split_clients "${remote_addr}AAA" $variant { 0.5% .one; 2.0% .two; * ""; } 一般来说,我明白这个指令是如何工作的,但我不明白AAA后缀的目的是什么。 请帮忙
Nginx具有一个很好的function,使您可以通过源IP地址来限制对资源的访问。 不过,我注意到,在nginx位于代理或负载均衡器后面的情况下,这可能不起作用。 在我的情况下,亚马逊ELB。 我想为datadog代理和Amazon ELB运行状况检查提供一个状态页面。 所以我想允许ELB的本地连接,但是否认一切。 以下内容不能按预期工作,因为它允许来自ELB之外的stream量也访问状态页面。 原因是因为IP似乎来自ELB,而允许规则不会查看标题来确定请求的真实来源。 有没有办法告诉nginx什么源IP来确定允许/拒绝规则? location /status { stub_status; access_log off; allow 127.0.0.1; allow 10.0.0.0/16; deny all; }
我正在使用nginx web服务器提供.pdf文件。 并根据title args使用重写规则设置.pdf文件的文件名。 我想要做的是,将我的域名example.com添加到文件名中 1.如果title var包含example.com ,则使用title var数据作为文件名。 例如 URL : http://example.com/pdf/0D2E8C9DC2F732A6ACC6150811515F697E3C376C.pdf?title=[example.com]ebook Filename : [example.com]ebook.pdf 2.如果title var中没有包含example.com ,则将文件名作为[example.com]title var.pdf 例如 URL : http://example.com/pdf/0D2E8C9DC2F732A6ACC6150811515F697E3C376C.pdf?title=ebook Filename : [example.com]ebook.pdf 3.如果标题没有设置,则使用文件名作为[example.com]hash.pdf文件名。 例如 URL : http://example.com/pdf/0D2E8C9DC2F732A6ACC6150811515F697E3C376C.pdf Filename : [example.com]0D2E8C9DC2F732A6ACC6150811515F697E3C376C.pdf 我怎样才能达到这样的东西。 ? 我目前的configuration看起来像这样 #pdf download block location ~* /pdf/([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F]+)\.pdf$ { #if title is not set then use hash.pdf as filename […]
Nginx worker_connections “设置工作进程可以打开的同时连接的最大数量,这个数字包括所有的连接(例如与代理服务器的连接等),而不仅仅是连接到客户端,另一个考虑因素是实际同时连接的数量连接不能超过最大打开文件数的限制“。 我对此有几点疑问: 什么应该是最佳或推荐值呢? 使用大量工人连接有什么缺点?
我有一个网站与nginx与以下要求: redirect所有http – > https 零停机让我们encryption证书更新 为了满足(1)我有一个小的http-> httpsredirect在我的nginxconfiguration。 为了满足(2)我将需要修改所述的configuration,以便我可以使用Webroot让我们encryption身份validation方法。 我试图找出满足这两个要求的最佳解决scheme。 我已经拿出了以下,这是有效的。 之前: server { listen 80; server_name example.com; return 301 https://example.com$request_uri; } 后: server { listen 80; server_name example.com; location ~ /\.well-known\/acme-challenge { root /usr/share/nginx/html; allow all; } if ($request_uri !~ /\.well-known) { return 301 https://example.com$request_uri; } } 但是,我希望找出另一种方法。 原因是: 如果是邪恶的 。 在这种情况下可能不会这么大,因为这只是http-> httpsredirect,应该是非常低的stream量。 更重要的是,避免使用if会更容易将webrootauthenticationlocking到所有在nginx后面运行的站点,因为我可以在.conf中插入location指令,然后我可以在我所有的小型http- […]
我需要从nginx提供一些FCGI脚本(通过WSAPI ,但这是无关紧要的)。 目前我正在使用spawn_fcgi来做到这一点。 这是我find的唯一解决scheme。 我需要知道我的其他选项。 有没有其他的方法来运行nginx下的FastCGI?
我想看看如何configurationNginx和Varnish。 我在两个IP上运行多个PHP站点和Rack-Sinatra站点作为虚拟主机。 我想阻止Nginx提供静态文件,因为我注意到一些延迟。 编辑 :我已经更改为Nginx,但提供的答案很容易移植到Nginx。
我试图安装phusion乘客nginx模块,但它失败 # passenger-install-nginx-module * Curl development headers with SSL support… not found … yum install curl-devel Setting up Install Process Package curl-devel-7.15.5-9.el5.x86_64 already installed and latest version Package curl-devel-7.15.5-9.el5.i386 already installed and latest version Nothing to do 还有什么需要做的? 我用的是:CentOS 5.2,Phusion Passenger 3.0.0,nginx / 0.8.53 # gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure […]
我已经尝试了很多变体的configuration,但我仍然无法得到它的工作,因为它应该。 有什么build议么? location ~ /views/(.+)\.php$ { deny all; } configuration: server { listen 80; server_name …; #charset koi8-r; #access_log logs/host.access.log main; location / { root /srv/www; index index.php index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 […]