任务:nginx使用dynamic查找和caching为反向代理configuration泊坞窗容器。 处理stream程: 检查caching。 如果上游发现 – 代理 如果找不到 – 请求它,caching和代理 如果发现但caching无效 – 清除caching并再次运行 当前configuration(模板): server { listen *; server_name {{host}}; set $attempt 0; location / { try_files '/dev/null' @run; } location @run { internal; set $container_name "{{container_name}}"; set $upstream ""; rewrite_by_lua ' local attempt = tonumber(ngx.var.attempt) if attempt > 1 then ngx.log(ngx.ALERT, "Upstream down") ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR) end […]
这是我的service nginx status命令的结果。 (Debian 8 64bit) Loaded: loaded (/lib/systemd/system/nginx.service; enabled) Active: active (running) since Fri 2015-09-18 12:20:23 CEST; 2h 29min ago Process: 31845 ExecStop=/sbin/start-stop-daemon –quiet –stop –retry QUIT/5 –pidfile /run/nginx.pid (code=exited, status=2) Process: 29093 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS) Process: 31851 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: […]
我想用AwStatsparsingnginx访问日志。 指定的nginx日志格式是 '$remote_addr – $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; 和日志似乎被正确创build。 AwStats日志格式是 LogFormat = "%host – %logname %time1 %code %methodurl %bytesd %refererquot %uaquot %otherquot" 当我尝试从命令行运行它时,我得到以下错误输出: Running '"/usr/lib/cgi-bin/awstats.pl" -update -config=default -configdir="/etc/awstats"' to update config default Create/Update database for config "/etc/awstats/awstats.conf" by AWStats version 7.2 (build 1.992) From data in log file "/…/****-access.log"… […]
自2015年9月9日起,我们正在观察从javascript发送到我们系统的一些奇怪的行为。 当查询string发送到我们的服务器时,问题就出现了。 获取请求中包含参数的某些值是混洗的。由于参数完全变形,因此无法映射接收到的数据。 例如,参数'foo = bar'会得到'foo = abr'或'foo = rab'。 这意味着数据仍然可用,但字符不再是正确的顺序。 这只发生在长度超过8个字符的参数上。 我们根据查询string的jenkins散列来计算校验和。 由于string只有6个字符长,所以校验和得到正确传输。 GET请求在计算校验和后立即发送到我们的系统。 这就是为什么问题不应该在JavaScript中。 分析我们的服务器的访问日志显示,这些参数在收到时已经被打乱了。 现在,我们只能在Mozilla Firefox用户代理和Microsoft Windows操作系统上观察到这个问题。 来自昨天的错误请求示例显示了以下用户代理: Mozilla / 5.0(Windows NT 10.0; rv:40.0)Gecko / 20100101 Firefox / 40.0 Mozilla / 5.0(Windows NT 10.0; WOW64; rv:38.0)Gecko / 20100101 Firefox / 38.0 Mozilla / 5.0(Windows NT 10.0; WOW64; rv:40.0)Gecko / 20100101 Firefox / […]
我在我主持的wordpress网站上发生DoS攻击。 173.192.109.118 – – [30/Sep/2015:22:31:36 +0000] "POST /xmlrpc.php HTTP/1.0" 499 0 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)" 我在我的nginx访问日志中获得了大约140个这样的日志(大概需要10秒,所以〜14次/秒),然后他们切换到502: 173.192.109.118 – – [30/Sep/2015:22:31:46 +0000] "POST /xmlrpc.php HTTP/1.0" 502 537 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)" 此时,必须重新启动PHP-FPM才能恢复站点。 所以,我的问题是: 有什么我可以做的,以防止一个单一的攻击者崩溃PHP-FPM ? 我的(有限的)经验大部分是与Apache,所以任何意见将不胜感激。 我试图设定一切合理的限制。 服务器有足够的内存负载,所以这似乎不是问题。 我刚刚添加了一个速率限制器,从以下教程: https : //www.howtoforge.com/rate-limiting-with-nginx ,虽然这似乎延迟的痛苦,它仍然最终崩溃PHP-FPM 。 /var/log/php5-fpm.log似乎没有显示任何有趣或有用的东西,除了我忘记在configuration文件中添加前导/后引入的几个错误,以及一些成功行重新启动: [30-Sep-2015 23:03:51] ERROR: […]
我有一个nginx / pagespeed模块的问题。 图像caching时间是默认的第一页上的5分钟。 第一次: 第二次: 有在我的nginx.conf: ## # PageSpeed ## pagespeed on; pagespeed FileCachePath /var/ngx_pagespeed_cache; pagespeed Domain https://example.com; pagespeed Domain *.example.com; pagespeed MapOriginDomain "http://localhost" "https://example.com"; pagespeed LoadFromFile "https://example.com" "/usr/share/nginx/www/"; pagespeed LoadFromFileRuleMatch Disallow \.php$; pagespeed XHeaderValue "Powered By ngx_pagespeed"; pagespeed ListOutstandingUrlsOnError on; pagespeed EnableFilters extend_cache; # image related pagespeed EnableFilters rewrite_images; pagespeed EnableFilters convert_gif_to_png; pagespeed […]
在IIS 8.5之前使用nginx。 IIS 8.5已经configuration压缩并且工作得很好。 但是当我们通过nginx(config下面)来打开它时,gzip就会丢失(从Web浏览器的angular度来看)。 第1部分:解决scheme尝试#1是在nginx上启用gzip,它从浏览器的angular度带回gzip,但现在(我们担心)要么(a)施加双gzip开销(gzip in iis,解压缩nginx,re-gzip在nginx上); 或者,(b)gzip现在在nginx上,这是不理想的(因为我们对iis有更好的控制,而且iis可以更好地决定什么是静态的,什么是dynamic的,因此caching更好等)。 解决scheme#1的configuration可以在这里看到: nginx:服务器上的gzip在代理期间丢失 附录1:每个nginx文档( https://www.nginx.com/resources/admin-guide/compression-and-decompression/):“NGINX …不会”压缩“已压缩的响应” 这是好的,因为双压缩不会发生。 第2部分:我们真正想要的是让accept-encoding头从浏览器通过nginx到iis,让iis做所有的压缩,并通过nginx传递gzip的响应,而不会在nginx上发生任何gzip开销。 我们的运行configuration如下。 问题:我们如何在nginx 1.7.9中实现第2部分? 运行反向代理configuration,剥离所有gzip(例如它似乎去除了accept-encoding头): http { upstream sandbox_site { least_conn; # we pipe to back end on port 80 only, so that nginx handles all ssl server 192.168.2.16:80 max_fails=1 fail_timeout=60s; # sbox3-site is .2.16 } server { # This […]
我是nginx新手,我想要做的就是捕获所有的图像请求(* .jpg | png | gif),并将它们转发到根目录之外的php脚本。 我目前的工作脚本是这样的: server { index index.php; # PHP-FPM location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; } # Images handler root /var/www/images-handler; location ~* \.(gif|jpg|png) { rewrite ^ /img.php last; } } 问题是我必须将rootvariables更改为/var/www/website-contents 。 由于website-contents和images-handler没有相同的父目录,我添加一个rootvariables到我的location段像这样: root /var/www/website-contents; location ~* \.(gif|jpg|png) { root /var/www/images-handler; rewrite ^ /img.php last; } 但它不起作用。 所有的图像返回一个404响应。 […]
当我有这样的事情: location ~ .php$ { ## Execute PHP scripts if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss expires off; ## Do not cache dynamic content include fastcgi_params; ## See /etc/nginx/fastcgi_params fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param ID_DEVELOPER_MODE 1; } include指令在哪里很重要? 因为文件/ etc / nginx / fastcgi_params里面已经有一个SCRIPT_FILENAME声明了。
我configurationnginx 1.4运行cakephp 2.6,但它不能工作。 对于每个页面,例如http:// my-app /或http:// my-app / admin,它总是返回错误:错误:在文件App / Controller / Index.phpController中创build类Index.phpController。 PHP 我的应用程序configuration: server { server_name www.my-app; rewrite ^(.*) http://my-app$1 permanent; } server { listen 80; server_name my-app; root /usr/share/nginx/my-app/App/webroot; index index.php; include /etc/nginx/security; # Logging — access_log /var/log/nginx/my-app.access.log; error_log /var/log/nginx/my-app.error.log notice; # Not found this on disk? # Feed to CakePHP for […]