Articles of nginx

Nginx限制活动连接的数量

我正在运行一个网站,有时在很短的时间内获得非常高的负载。 因此,我希望避免在15分钟的时间内偶尔放置大服务器。 Nginx有没有办法检测到工作人员正在拖延,并将用户redirect到静态页面,而不是将更多的工作添加到PHP-FPM队列中? 我还需要web服务访问,至less发出特定的HTTP返回代码,以便移动应用程序可以显示一个很好的消息。 谢谢,尼古拉斯

replace$ args中的第一个字符

我想在rewritereplace$args的第一个字符 我有以下几点: return 302 https://domain/accounts/registration?_uid=1928&_tag=$request_uri&$args; 如果$args是空的,我只是得到一个以&结束的链接,这不是一个大问题,但如果我有一些$args我得到的something&?arg1这是错误的,因为&? 被认为是前一个参数的延续。 如何从$args删除第一个字母( ? )?

两个代理内的一个虚拟主机nginx

我尝试添加两个代理到一个虚拟主机/服务器定义来运行这个软件: https : //github.com/cybertec-postgresql/pgwatch2 PGwatch2监听不同的端口:一个pipe理软件,一个显示grafana仪表板。 我想在一个服务器定义中实现这两个代理,但我的例子只适用于主要位置。 /pipe理没有工作:404没有find。 server { listen 80; listen [::]:80; server_name pgwatch.xy.de; return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; ssl_certificate /etc/ssl/web/pgwatch.chain.pem; ssl_certificate_key /etc/ssl/web/pgwatch.xy.key; add_header Strict-Transport-Security "max-age=63072000; preload"; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; server_name pgwatch.xy.de; root /usr/share/nginx/html; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect […]

如何用Nginx中的其他URLreplace/ wp-admin?

我在我的网站上有一个WordPress,我想隐藏并保护对仪表板的访问。 它与Nginx一起工作在VDS内部。 我想访问者看到404错误页面,如果他访问/wp-login.php或任何/ wp-admin / *页面 但为了让我的团队访问仪表板,我希望他们访问这些页面的不同URL,如/log-in.php(要inputlogin凭据),并使仪表板在/ root / * URL可用。 以前,我使用插件来实现这一点,但他们只能使用Apache。

Nginx错误内存

我有一个Nginx + PHP的问题。 这是错误的 PHP message: PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 896464024 bytes) in /sistemas/html/producao_11003/prod/third/zipfile/zipfile.php on line 122" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: XXX.XXX.XXX.XXX, request: "POST /11003/BackupProcess/BackupProcess.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "xxx.xxx.xxx.xxx.", referrer: "https://xxx.xxx.xxx.xxx/11003/gerarBackup/gerarBackup.php" 我尝试增加php.ini中的memory_limit在我的info.php工作,但是当我再次运行命令我得到同样的错误。 在我的php-fpm这行有评论 ;php_admin_value[memory_limit] = 128MB.

更改所有者权限将打破nginx中的htdocs

Nginx以用户nginx运行,是组的一部分; 'nginx','andy'和'bob'。 我的htdocs具有以下权限: drwxr-xr-x andy andy 当我查看我的网站时,它工作正常。 Nginx是在安迪集团,我们可以看到上面的gorup权限允许读取。 我想改变htdcs和文件的所有者鲍勃。 Nginx是在BOB组,所以这应该仍然工作? 当我… chown -R bob:bob ./htdocs 我的许多文件返回302错误。 如果我把主人改回安迪(但是把这个小组留下来),所有事情都会重新开始。 那么肯定这意味着nginx是作为bob组的一部分拾取的?! 我不明白。 如果权限设置为允许读取该组,并且我的nginx用户是该组的一部分,那么为什么该所有者很重要?

主题文件的Nginx位置别名

我正试图将我的主题文件移到文档根目录之外。 我正在使用nginx的服务器,我已经尝试在位置块中使用别名和根指令。 没有我试过的作品,我怀疑这是try_files指令里面的location / 。 我在/var/www/naturesflowllc/ui/assets文件夹中有我的主题文件 这是我的nginx conf文件。 server { listen 80; listen [::]:80; server_name my.beupnow.dev.kahunacoding.com; root /var/www/naturesflowllc/mybeupnow/public_html; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_read_timeout 180; fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /assets/ { alias /var/www/naturesflowllc/ui/assets/; […]

nginx重写整个request_uri

我知道有很多这样的例子,但我只是想确定。 不幸的是我不能在接下来的几天内testing这个,所以我在这里问。 什么是这个位置的重写相当于? location ~* /v1/device/(.*)/ { proxy_pass http://api.domain.com/api/v1.0/download/$1; } 我想基本上重写整个传入的请求,除了regex的部分。 我认为这是但我不确定: location ~* /v1/device/(.*)/ { rewrite ^/v1/device/(.*)/ /api/v1.0/download/$1 break; proxy_pass http://api.domain.com; } 想知道是否有更干净的方式,而我不必在重写规则中重复/ v1 / device /。 谢谢

WordPress的网站域更改和jQuery中断; 基于nginx的

试图解决为什么jQuery不工作后,我更改WordPress的网站url中的域名。 我在nginxdebugging日志中收到这些消息… 2017/10/18 16:01:59 [info] 6657#6657: *495 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while reading upstream, client: 221.234.103.135, server: example.com, request: "GET /wp-includes/js/wp-emoji-release.min.js?ver=4.8.2 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "example.com", referrer: "http://example.com/"; 2017/10/18 16:02:03 [info] 6657#6657: *498 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too […]

Varnish年龄是0(代理通过nginx到节点应用程序)

我想添加清漆到现有的networking堆栈,但我似乎无法得到我的网页的caching版本。 我想知道我可能做错了。 这个configuration工作,但我没有得到从清漆回来的caching响应: 1. Nginx is listening on port 443, request proxied to Varnish 2. Varnish is listening on port 80, request proxied to Node App 3. Successful Response 我试过了: curl -kIL https://www.example.com HTTP/1.1 200 OK Cache-Control: public, max-age=30 Set-Cookie: locale=en-ca; Path=/ Set-Cookie: locale=en-ca; Path=/ Content-Type: text/html; charset=utf-8 Content-Length: 161861 ETag: W/"27845-EcqEhuo8dduXo4rrAF4EfS6igbQ" Vary: Accept-Encoding Date: […]