Articles of nginx

Nginx的limit_req_zone忽略率值

我有一个奇怪的行为我的configuration看起来像这样: http { limit_req_zone $binary_remote_addr zone=nocachelimit:10m rate=120r/m; } … location "/api" { { limit_req zone=nocachelimit burst=20; } } 无论我把什么价值放入速度,我甚至尝试1000r / s我不断获得“普通”用户的日志条目,说: [warn] 16526#0: *4661 delaying request, excess: 1.000, by zone "nocachelimit" 典型的用例是一个不属于区域+ 4-5的Ajax请求的页面负载,它将被限制在区域内。 这种行为可能是什么原因呢?

Nginx的proxy_pass总是发送到

我遇到了从Nginxredirect到gunicorn的问题。 我使用proxy_passredirect到https://127.0.0.1:5000 ,但redirect发送到https://[::1]:5000 。 这里是我自己的.conf文件,它包含在nginx.conf : server { listen 80; server_name mydomain.no www.mydomain.no myotherdomain.no; return 301 https://$server_name$request_uri; } server { listen 443 ssl; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; server_name mydomain.no www.mydomain.no myotherdomain.no; ssl_certificate /path/to/chain; ssl_certificate_key /path/to/private/key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; root /var/www/html/; index index.html; charset UTF-8; location /api { proxy_set_header X-Real-IP $remote_addr; proxy_set_header […]

只有当.php被添加参数时,Nginx才会将.PHP作为下载文件

这是我目前的nginxconfiguration: server { server_name mydomain.example; access_log /srv/www/mydomain.example/logs/access.log; error_log /srv/www/mydomain.example/logs/error.log; root /srv/www/mydomain.example/public_html; error_page 404 /404; location / { if ($request_uri ~ ^(.*)\.(php|html)$) { return 302 $1$is_args$args; } try_files $uri $uri/index.html $uri/index.htm @php; index index.html index.htm index.php; } location @php { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; try_files $uri.php $uri/index.php =404; } location /support […]

用YUM安装Nginx的“Headers More”模块

我真的想避免自定义修补/编译的东西,因为升级是一场噩梦。 在Nginx上,我使用yum安装了nginx18,我还想启用stream行的模块: https ://www.nginx.com/resources/wiki/modules/headers_more/ 但是,很难find有关如何以百胜友好的方式启用该模块的任何说明。 有人可以指示我指示,或提到命令? 谢谢。

nginx位置redirect到名称为请求域的文件夹

我是nginx新手,我想这样做: If the URL contains "/assets" redirect to "/communities/$url_domain" 换一种说法: Requested: "http://www.cats.com/assets/superfile.png" Redirected:"http://www.cats.com/communities/cats.com/superfile.png" 这是超级简单但不起作用的东西。 我做了什么 location /assets { root /communities/$host; } 但每当我尝试从/资产访问文件,我得到一个 404 Not Found nginx/1.8.1 我做错了什么? 谢谢! 编辑: 我激活日志,看到这个: 2016/02/10 17:27:16 [error] 31#0: *1 open() "/communities/www.cats.com/assets/superfile.png" failed (2: No such file or directory), client: 192.168.1.254, server: _, request: "GET /assets/superfile.png HTTP/1.1", host: "www.cats.com" 我会调查更多如果我可以提取url的域名部分 […]

mod_rewrite问题在Nginx后面的Apache

我有nginx代理到Apache作为后端为了nginx处理静态资产。 不幸的是,当我试图访问一个“漂亮的url”,它只是显示索引页面。 nginxconfiguration server { listen 80; root /var/www/example.com; index index.php index.html index.htm; server_name example.com www.example.com a.example.com b.example.com c.example.com; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } location ~ /\.ht { deny all; } } Apache vhostconfiguration <VirtualHost 127.0.0.1:8080> […]

Apache2和nginx每周都会随机地消耗所有的内存

我想在此前言说我已经阅读了至less10个相关的Serverfault问题,然后才决定自己做… 我目前正在运行带有2GB内存的Ubuntu 14.04.3服务器,以及大约5个有效的WordPress安装,全部在Vesta CP控制面板下进行pipe理。 通常情况下,它消耗了大约700MB的2GB。 但是每个星期左右,所有的RAM都会被神奇地消耗掉,服务器的速度几乎停顿下来。 如果我SSH进入并重新启动Apache,以及清除内存( echo 3 > /proc/sys/vm/drop_caches ),它再次开始正常工作。 这里是我的prefork模块设置,我觉得是非常合理的: <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 1 MaxSpareServers 5 ServerLimit 10 MaxClients 10 MaxRequestsPerChild 1000 </IfModule> 我甚至启用了mod_status,并试图查看哪些PHP文件花了太长时间,但没有发现任何可疑的东西。 当然,当我查看服务器停机的日志时,由于大量的内存消耗而无法运行,因此至less有200个PHP文件被淹没。 我甚至启用了一个8GB的SWAP文件,但似乎只是推迟了不可避免的。 以下是free -m命令每次提取的内容: root@apache2-ps7881:/home/dhc-user# free -m total used free shared buffers cached Mem: 2001 1943 57 35 1 59 -/+ buffers/cache: 1883 118 Swap: 8191 […]

Docker组合和nginx负载均衡器

目前我有2个Docker容器: 应用程序(python烧瓶) 负载平衡器(nginx) 我使用docker-composer分别启动两个容器Nginx正在侦听端口8080,并且应该将HTTP请求转发到正在侦听端口8081的应用程序。目前这不起作用,因为nginx不知道有关应用程序容器的任何信息。 86615a5b0f02 parzee/loadbalancer "/usr/local/bin/start" 3 minutes ago Up 3 minutes 127.0.0.1:8080->8080/tcp loadbalancer_loadbalancer_1 9adc8a04b356 parzee/application "/usr/local/bin/start" 6 minutes ago Up 5 minutes 127.0.0.1:8081->8081/tcp application_application_1 这是我的默认configuration upstream application { ip_hash; server application_application_1:8081 fail_timeout=0; server application_application_2:8081 fail_timeout=0; keepalive 64; } server { listen 8080; server_name loadbalancer; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { proxy_set_header X-Forward-For […]

nginx在目录中组织节点js站点

我在DigitalOcean VPS上运行多个NodeJS站点,并希望将站点组织到由其域名标记的文件夹中,例如busstopcards.co.uk。 不幸的是我的/ etc / nginx / sites-available / default不工作,域不parsing到节点应用程序 server { listen 80; server_name busstopcards.co.uk; root /home/user; location /busstopcards.co.uk { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } } 请有人build议一个解决scheme谢谢大卫

nginx可以在同一个虚拟机上同时运行gitlab和taiga.io吗?

我在同一台虚拟机上运行GitLab和Taiga.io (即共享相同的IP)有困难。 两者都使用nginx。 我的虚拟机运行Debian 8。 我遵循Debian 8的GitLab的经典Omnibus安装 ,当我在浏览器上input我的虚拟机的IP时,gitlab被正确的服务,并且一切顺利。 然后closures它( sudo gitlab-ctl stop ),然后按照生产环境设置安装Taiga。 根据该文档,它使用Gunicorn和Circus for taiga-back(服务于REST API)以及用于服务前端的nginx。 一旦/etc/nginx/sites-available|enabled/taiga , ~/taiga-back/settings/local.py和~/taiga-front-dist/dist/conf.json都使用相同的IP地址设置,而nginx重新启动( sudo service nginx restart )一切顺利。 现在,可以使用不同的端口(比如说8080 )来更改上述的所有Taiga IP地址,重新启动nginx,并且现在通过IP地址8080提供Taiga。 一切都好! 当我重新启动GitLab( sudo gitlab-ctl start )时,它说一切顺利。 但是,当我尝试访问它(在默认端口80),我得到一个502 ! 如果我切换Taiga并重新启动GitLab,hoho,GitLab可用! 基本上,我只能单独拥有它们,但不能同时拥有它们。 我也尝试在Taiga 80端口上保留Taiga,并在8080端口上移动GitLab(通过更改/etc/gitlab/gitlab.rb文件中的端口并运行sudo gitlab-ctlr reconfigure ),但是我从未设法成功运行它。 我也试着configurationGitLab使用系统nginx(而不是embedded的),也就是Taiga使用的系统。 为此,我在gitlab.rb后面的gitlab.rb禁用了nginx,并使用了这个omnibus(non-ssl)配方: ## GitLab 8.3+ ## ## Lines starting with two hashes […]