Articles of nginx

将Nginx_status捕获到zabbix(v3或更高版本)

我想知道是否有一个模板捕获nginx_status到zabbix。 最近search了几个小时,但他们的模板只适用于早期版本。 先谢谢你

Docker nginx:redirect到端口80而不是映射端口

我正在制定这个wordpress解决scheme,并为了“节食”的原因,我正在进入阿尔卑斯山的形象。 在这个我设法使用外部configuration( 文件 )和通过卷我把它传递到nginx。 server { listen 80; root /var/www/html; index index.php; location / { try_files $uri $uri/ /index.php; } location ~ .php{ try_files $uri =404; fastcgi_pass wordpress:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME […]

NginX – 重写http_referer

我使用Nginx作为我的后端服务器的代理。 而我的应用程序将存储所有引用url到数据库。 为了减less数据库的空间,我想在某些情况下忽略一些引用者。 如果uri包含一些string,我想删除一些http_referer。 由于nginx不能在“if {…}”中使用[proxy_set_header Referer“”] 所以,我尝试使用“地图”,但它仍然不起作用。 这是我的configuration http { …. map $http_referer $ref { default $http_referer; } …. } server { …… if ($request_uri ~ .*XXXXXXX.*) { set $ref ""; } proxy_set_header Referer $ref; …… } 我可以创build一个variables$ ref 它可以通过使用“proxy_set_header Referer $ ref”将$ ref映射到头部, 但是“if”不能改变$ ref的值 难道我们不能在“if”里面改变全局variables吗?

nginx在root密码更改后拒绝连接

这太奇怪了 我用serverpilot使用数字海洋。 我更改了服务器的根密码,并且该站点已closures。 root@niche-hunter:/# sudo service nginx-sp restart Job for nginx-sp.service failed because the control process exited with error code. See "systemctl status nginx-sp.service" and "journalctl -xe" for details. root@niche-hunter:/# journalctl -xe — Subject: Unit nginx-sp.service has begun start-up — Defined-By: systemd — Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel — — Unit nginx-sp.service has begun starting up. Aug 19 […]

NGinX + PHP-FPM微服务死锁

我有许多小型服务在两台服务器上运行: 服务器A)pipe理高安全性服务:用户帐户和个人消息。 服务器B)pipe理低安全性服务:图像上传和公共资料。 问题在这里。 在不可预知的时间间隔内,服务器将开始超时,CPU,内存或磁盘活动不会显着。 我很快发现问题在于服务器A正在运行两个互相依赖的服务。 在这个例子中,我将它们称为服务AA和AB。当服务AB收到请求时,它会使AA以类似于oAuth的方式检索有关用户帐户的数据。 我确定这个问题是PHP-FPM中的一个僵局。 当服务AB接收到n个请求(n是允许产生同时进程的PHP-FPM的数量)之后,它已经设法向同一台机器上的服务发出请求,它将开始排队请求。 显然,如果它已经分配了所有的进程,PHP-FPM将停止处理任何新的请求。 不幸的是,这包括它在同一台服务器上的请求。 因此,服务器将实际上已经死亡(服务器B与它一起)。 起初,我发现解决scheme相当简单:我创build了几个PHP-FPM池,允许应用程序并行运行。 这可以缓解这个问题,因为它现在允许PHP-FPM创build更多的stream程,但是不能解决这个问题。 我不确定问题的确切原因是什么,但是由于问题似乎没有改变:服务器将闲置,但为其中一个服务产生了最大数量的PHP-FPM进程。 我认为现在Nginx已经陷入了僵局。 我不想声明如何nguni工作,但据我所知,如果有n + 1(n仍然是一个池的PHP-FPM进程限制)服务AB的请求 – 这取决于AA – NginX会等待PHP-FPM接受这个请求。 想知道是否有两个不同的服务有“两个请求队列”的选项,或者如果我的方法有什么问题的话。 – 当然,如果有任何诊断/日志,我应该运行/提供。 我会很乐意提供。

nginx代理caching不起作用

我是一个外部JSON API的代理,并试图caching代理响应。 要确定代理caching是否正在工作,我已经添加了 add_header X-Cached $upstream_cache_status; 并总是看到一个MISS值。 我的nginxconfiguration位置: location /api/tides { proxy_hide_header Cache-Control; proxy_ignore_headers Cache-Control; proxy_cache worldtidecache; proxy_set_header Host www.worldtides.info; proxy_pass https://example.com/api/$query_string; add_header X-Cached $upstream_cache_status; } 在此之前,我已经设置了proxy_cache_path proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=worldtidecache:100m max_size=1g inactive=48h use_temp_path=off; www-data具有对/var/cache/nginx读/写访问权限 我假设proxy_buffering设置为on因为我没有任何明确的设置。 nginxconfiguration是有效的。 我用nginx -c nginx.conf -ttesting了它nginx -c nginx.conf -t : ╰─sudo nginx -c nginx.conf -t nginx: the configuration file /etc/nginx/nginx.conf […]

Nginx使用-cc-opt和with-ld-optconfiguration选项

当我运行nginx -V我在输出中得到了这样的东西。 –with-ld-opt='-lrt -ljemalloc -Wl,-z,relro' –with-cc-opt='-m64 -mtune=native -g -O2 -fstack-protector –param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wno-sign-compare -Wno-string-plus-int -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-const-variable -Wno-conditional-uninitialized -Wno-mismatched-tags -Wno-c++11-extensions -Wno-sometimes-uninitialized -Wno-parentheses-equality -Wno-tautological-compare -Wno-self-assign -Wno-deprecated-register -Wno-deprecated -Wno-invalid-source-encoding -Wno-pointer-sign -Wno-parentheses -Wno-enum-conversion' 这是什么,以及如何从源代码编译nginx时知道哪些值需要去这里?

SSL:错误:02001002:系统库:fopen:没有这样的文件或目录

我有Ubantu 16.04 在/etc/nginx/sites-enabled#这个目录default文件包含如下代码: # HTTPS server server { listen 443 ssl; # we enable SPDY here server_name www.bitradiology.com; # this domain must match Common Name (CN) in the SSL certificate root html; # irrelevant index index.html; # irrelevant ssl_certificate /root/bitradiology.chained.crt; # full path to SSL certificate and CA certificate concatenated together ssl_certificate_key /root/bitradiology.key; # full […]

无法通过nginx将http://redirect到https://

大家好, 我已经在Ubuntu实例上设置了一个Nginx Web服务器。 我已经configuration了/ etc / nginx / sites-enabled / default文件,如下所示: server { listen 80; #listen IPv4 listen [::]:80; #listen IPv6 server_name my.domain.de; return 301 https://$host$request_uri; #redirect to https:// } server { listen 443 ssl spdy; #listen IPv4 listen [::]:443 ssl spdy; #listen IPv6 error_log /var/log/nginx/rocketchat_error.log; ssl_certificate /etc/letsencrypt/live/my.domain.de/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/my.domain.de/privkey.pem; # […]

Nginx服务器返回404除了索引之外的所有php页面

我用nginx和php 7.1安装了一个新的服务器。 当我想打电话给myurl.com/page时,它会返回一个404.当我打电话给myurl.com/时,一切都很好。 我已经在我的nginxconfiguration中添加了这个: location ~ \.php$ { include snippets/fastcgi-php.conf; # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.1-fpm.sock; }