在nginxconfiguration中,如果给定wordpress图像命名/大小符号约定,找不到所需的图像大小时,返回原始图像的最佳方法是什么。 所以,如果找不到/image-name-150×170.png,我想要返回/image-name.png。 -150-170部分可以是其他一些数字。 因此,我想在文件名中的点前1-4位数字x 1-4位删除。 我想把replace在uri代码里面@static_full位置块或重写。 想知道哪个更好的performance明智。 #some locations here and then location ~* ^.+\.(png|gif|jpg|jpeg){ access_log off; log_not_found off; expires max; error_page 404 = @static_full; #if not found, seek #static_ful } location @static_full{ #modify uri here to remove image dimensions like below #uri = remove dash 1-4 digits x 1-4 digits before dot #or rewrite […]
那里有很多机器人。 雄伟的机器人是其中之一。 它有时会强行抓取网站的页面,即服务器有时在1秒内发送100个请求。 雄伟的机器人只是一个例子。 我不想阻塞某个bot,有很多bot,试图检测它们是浪费时间。 我的问题是:我如何限制某个机器人发送给Nginx服务器的HTTP请求? 举例来说,在1秒内只允许10个IP地址的请求。 而且这个操作是否消耗明显的资源(因为IP地址应该被检查并存储在某个地方)?
我使用ngx_pagespeed优先考虑critcal css,以避免渲染阻塞: pagespeed EnableFilters prioritize_critical_css; 页面中的CSS被重写。 我在头部看到了内联的CSS,文档的末尾有一个JavaScript,用于在页面加载完后获取完整的CSS文件: <noscript class="psa_add_styles"><link rel="stylesheet" type="text/css" href="//<snip>/A.057d0b965aad0c0050fe7a0f69b3c864.1484761003.css.pagespeed.cf.oDO-xbYwbq.css" media="all"/></noscript><script data-pagespeed-no-defer type="text/javascript">(function(){function b(){var a=window,c=e;if(a.addEventListener)a.addEventListener("load",c,!1);else if(a.attachEvent)a.attachEvent("onload",c);else{var d=a.onload;a.onload=function(){c.call(this);d&&d.call(this)}}};var f=!1;function e(){if(!f){f=!0;for(var a=document.getElementsByClassName("psa_add_styles"),c=0,d;d=a[c];++c)if("NOSCRIPT"==d.nodeName){var k=document.createElement("div");k.innerHTML=d.textContent;document.body.appendChild(k)}}}function g(){var a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||null;a?a(function(){window.setTimeout(e,0)}):b()} var h=["pagespeed","CriticalCssLoader","Run"],l=this;h[0]in l||!l.execScript||l.execScript("var "+h[0]);for(var m;h.length&&(m=h.shift());)h.length||void 0===g?l[m]?l=l[m]:l=l[m]={}:l[m]=g;})(); pagespeed.CriticalCssLoader.Run();</script></body> 但是,即使使用此设置,PageSpeed Insights仍然会将上述JavaScript提取的CSS文件报告为render-blocking: 我是否错过了一些东西,或者不应该考虑这个CSS文件来阻止渲染?
我正在运行一个Nginx服务器,通过SSL为我的网站提供服务。 对于SSL支持,我使用LetsEncrypte。 sites-available Nginxconfiguration文件sites-available如下所示: server { listen 80; server_name domain.nl anotherdomain.nl; # return 301 https://$server_name$request_uri; return 301 https://domain.nl$request_uri; } server { listen 80; server_name www.domain.nl; return 301 $scheme://domain.nl$request_uri; } server { listen 443; server_name domain.nl; # SSL ssl_certificate /etc/letsencrypt/live/domain.nl/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.nl/privkey.pem; include snippets/ssl-params.conf; location / { proxy_pass http://localhost:6000; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header […]
假设我有一个域名为fish.example.com的logging,指向一个运行apache / nginx的http服务器,并为该域名设置了虚拟主机。 我也从cow.example.net创build一个CNAME到fish.example.com 什么域最终在我的apache / nginx,这是行为可configuration的Apache / Nginx?
重写在不同的Web服务器上总是那些吸pipe,为我打破了驼背。 现在我在服务器configuration中有以下内容: rewrite ^/(.+)$ /index.php?/$1 last; 现在,我需要确认,我在服务器上打开的任何URL都必须得到/ 。 但是,如果URL有参数,尾部/将被忽略。 url可能如下所示: http://domain.tld/testing/ // is okay http://domain.tld/testing // should be redirected with trailing slash http://domain.tld/testing#param // should be left alone 我尝试了以下内容: rewrite ^([^.\#]*[^/])$ /$1/ permanent; rewrite ^/(.+)$ /index.php?/$1 last; 但是它做了什么,它只留下带有斜线的url,但是如果一个url没有,那么它会redirect到http://domain.tld/index.php//testing/甚至是http://domain.tld/index.php//testing/#param使用参数时。
我现在要通过nginx在Google Compute Engine上部署我的node.js应用程序,但在完成所有configuration之后,我用“502 Bad Gateway”(502错误网关)错误触发了墙。 然后,在挖掘了这么多小时之后,我终于发现/etc/nginx/sites-available/server.conf中的proxy_pass字段应该是您在GCE控制台中显示的实际内部IP地址,而不是http://127.0.0.1 。 conf文件如下(有些值只是为了说明的目的): server { listen 80; listen 443 ssl; server_name example.com; ssl_certificate /etc/nginx/ssl/example.crt; ssl_certificate_key /etc/nginx/ssl/example.key; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://10.102.24.152:8888; } } 但是,我所遵循的所有教程都将proxy_pass的值设置为http://127.0.0.1 。 但在我的情况下,根本没有工作。 教程的例子如下: https://github.com/ShoppinPal/gcp-scripts/wiki/Setup-Nginx-on-Google-Cloud http://support.ghost.org/setup-ssl-self-hosted-ghost/ https://www.digitalocean.com/community/questions/problem-with-ssl-and-ghost 所以我现在想知道是否是使服务器正常工作的正确方法。 或者这是否导致安全问题容易发生? 或者,也许127.0.0.1是正确的数字,我身边还有其他问题?
我有一个全新的应用程序Nginx安装rails应用程序。 一切工作顺利,直到我决定把来自Letsencryption的SSL证书。 当我尝试访问页面时,出现404 Not Found错误。 /error.log 2017/02/07 02:10:46 [alert] 4779#0: *35005 2048 worker_connections are not enough while connecting to upstream /etc/nginx/nginx.conf user nginx; worker_processes 2; worker_rlimit_nofile 30000; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /run/nginx.pid; events { worker_connections 2048; } server{ listen 80; server_name example.com www.example.com; return 301 https://$host$request_uri; } server{ listen 443 […]
所以,我正在尝试让Nginx通过https服务我的网站,但它一直在打我,拒绝连接错误。 所以这里的输出是: curlhttps://juristnet.ro (这是网站) curl: (7) Failed to connect to juristnet.ro port 443: Connection refused netstat -anltp tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN – tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN – tcp 0 0 […]
netstat输出: tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN – tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN – UFW处于非活动状态。 该网站在数字海洋上的一个水滴托pipe,他们允许所有的端口。 如果我运行tcpdump并尝试访问网站,它显示一个连接,但浏览器返回拒绝连接错误。 本地主机上显示端口443是打开的,但如果我在实际的服务器上运行它,它显示它是closures的。 如上所示,Nginx正在端口443上正确侦听。 Nginx.conf user admin root; worker_processes auto; error_log /var/log/nginx/error.log debug; pid /var/run/nginx.pid; events { worker_connections […]