我正在寻找一种方法让我的nginx具有合理的能力来自动阻止各种恶意请求。 例如,因为它不提供任何PHP脚本,任何请求脚本小子似乎指向我的服务器的PHP URL应该导致立即(暂时)禁止该IP。
所以我有一个像Nginx的设置 – > varnish – > apache2如果我得到一个带有静态文件的请求,它会通过nginx发送到varnish,再次返回给nginx,因为它比apache2服务器快得多。 我的问题是,当我做一个 sub vcl_fetch { set beresp.http.X-Tabulex-Client = client.ip; 看看客户端的IP地址是127.0.0.1(X-Tabulex-Client 127.0.0.1)在vcl_recv中我有: sub vcl_recv { if((!req.url ~ "^/typo3temp/*" && !req.url ~ "^/typo3/*") && req.url ~ "\.(jpg|css|gif|png|js)(\?.*|)$") { set req.backend = aurum; set client.identity = req.http.X-Forwarded-For; } elseif(client.ip == "192.168.3.189") { /* Traffic from the other Varnish server, serve using real […]
我有以下nginxconfiguration(在/etc/nginx/sites-available/default ) server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default ipv6only=on; ## listen for ipv6 root /usr/share/nginx/www; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.html; } error_page 404 /404.html; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_index […]
Web服务器:Nginx。 检查我们的日志文件,有许多连接日志条目: 需要59-61秒 发送一个空的请求(或至less没有被logging) 导致408响应(请求超时) 不包含任何http_user_agent 起源于数量有限的IP 我们正在监测平均服务时间,这显然使我们的统计数据膨胀。 除此之外,这是一个问题吗? 任何想法为什么发生? 这是否暗示有人故意搞乱我们? 我们应该做什么?
在我的nginx conf中,我已经启用了gzip: gzip on; gzip_proxied any; gzip_types text/plain text/css text/javascript; gzip_comp_level 9; gzip_vary on; 但是这也gzips我的jpeg的实际上增加大小。 我如何,理想的情况下使用位置,禁用gzipping的图像?
我使用nginx作为单个机器的反向代理。 我想在后台机器出现故障时出现错误页面。 这是我的configuration文件: server { listen 80; access_log /var/log/nginx/access.log; root /var/www/nginx; error_page 403 404 500 502 503 504 /error.html; location / { proxy_pass http://192.168.1.78/; include /etc/nginx/proxy.conf; }
在nginx.conf中: http { geoip_country /etc/nginx/GeoIP.dat; … } 如果我做: server{ … location / { add_header X-Geo $geoip_country_code; add_header X-Geo3 $geoip_country_code3; add_header X-IP $remote_addr; … } } 只有X-IP显示在我的标题中。 $ curl -I www.example.org HTTP/1.1 302 FOUND Content-Type: text/html; charset=utf-8 Date: Thu, 17 Jan 2013 19:29:23 GMT Location: http://www.example.org/login/?next=/ Server: nginx/1.2.2 Vary: Cookie X-IP: 10.139.34.12 Connection: keep-alive 如果我将位置块更改为: location […]
我需要赶上,如果我的url包含一个小的substr,保持原有的url,只重写那小部分,我怎么能做到这一点? 例如: http://foobar.com/foo-bar-substrtocatch-baz 应该成为 http://foobar.com/foo-bar-changedsubstr-baz 提前致谢…
我有一个nginx服务器充当我的apache服务器的负载平衡器。 我正在使用子域,我的代码依赖于HTTP_HOST值来执行正确的任务。 当我发出请求说: http://get.example.com : http://get.example.com一旦它被转发Apache的HTTP_HOST成为example.com 。 我的问题是如何使它保持原来的要求相同? 这是我的nginxconfiguration: upstream example.com { server 192.168.2.1:8909 weight=2; server 192.168.2.2:8909 weight=1; server 192.168.2.3:8909 weight=1; } server { listen 80; location / { proxy_pass http://example.com; } } 我试图添加多个proxy_pass ,每个子域的一个,它似乎并没有工作。
在我的Ubuntu 12.04的nginx(1.4.2)设置中,我只设置了一个configuration文件(我删除/禁用了其他的): server { listen [::]:80 default_server; location / { root /home/lwood/websites/default/public; } } 我重新启动了nginx。 为什么nginx不接受IPv4连接? 这里是文档 http://wiki.nginx.org/HttpCoreModule#listen 他们提到这一点 在Linux中默认情况下,任何IPv6 TCP套接字也接受IPv4stream量…运行时参数:net.ipv6.bindv6only默认值为0。 我已经检查了与sysctl ,bindv6only确实设置为0.所以我的IPv6侦听指令也应该接受IPv4,对吧? 我一定是误解了文档。 一个解释将不胜感激。