我想为所有的域名制定一般规则,所以我不必单独指定每个域名。 我在我的Apacheconfiguration文件中有这两行: RewriteCond %{HTTP_HOST} ^domain\.com RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,QSA] 现在我有更多的域指向同一个目录。 而我将不得不重复这两行每个域。 我试图编辑这个条件和规则,但没有成功,使他们通用的任何域没有实际指定的域名。 可能吗 ?
我想在nginx中设置代理: location ~ ^/m/([^/]*)/([^/]*)/([^/]*)$ { proxy_pass http://127.0.0.1:8080/redir/m/$1/$2/$3; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } 它的工作,但这个地址 http:// myhost/m/test//ss 被翻译成 http:// 127.0.0.1:8080/redir/m/test/ss; 我怎么能得到我的第二个斜杠? 感谢名单。
我怎么能写的正则expression式的后缀头检查拒绝所有的邮件与X-Source-Dir有abc/def ? 这个可以吗? /^X-Source-Dir:\s(.*abc\/def.*)/ REJECT due to spam: 非常感谢Ladadadada 🙂 但是, /^X-Source-Dir:\s(abc|def)/ REJECT due to spam: 所有来自dir / abc / def的邮件都会被拒绝。我的要求是,拒绝来自“/ home / user / public_html / templates / beez”的邮件。 我尝试了下面给出的标题检查: /^X-Source-Dir:\s(.\*templates.*|.\*wp-content.\*)/ REJECT The message was rejected due to classification as spam from CMS 但问题是这也会拒绝源代码目录的邮件为/home/user/public_html/templatesabc.com/ 请协助。
我已经沮丧了几天想弄明白这一点,所以任何意见/帮助将不胜感激! 我最近在somehost.com上添加了一个名为/links到某个站点的部分,但似乎无法得到这个目录的重写规则(见下文)。 域的所有其他path工作正常(例如说一些hosthost /浏览器/video/无论redirect到somehost.com/by/whatever/罚款)和所有其他重写规则似乎仍然工作很好,这只是新添加location /links/部分我的conf在东西分崩离析。 下面的conf在第27行失败 – 使用service nginx restart时得到的错误是: 指令“rewrite”没有以“;”结尾。 但是我可以看到终点线终止于一个; 所以我不确定有什么问题。 也许正则expression式的东西? 我的nginx conf在下面。 任何想要改变什么来获取像somehost.com/links/page/3或somehost.com/links/tag/sometopic/page/2工作的url? 谢谢! server { server_name somehost.com; listen 80; root /var/www/somehost.com; include /etc/nginx/php.conf; location / { index index.php; access_log /var/log/nginx/somehost.com.log; #handle old variable redirects first, before dealing with current permalinks rewrite ^/?browse/video/(.*) /by/$1 permanent; #set a 30-day expires header on […]
抓我的头在这个。 我有一个旧的url: http://myserver/blog/archive?openview&type=Category&key=Demo 和一个新的URL http://myserver/blog/categories/Demo 我试图得到这个重写规则。 我认为这将是: ^/blog/archive\?openview&type=Category&key=(.*) /blog/categories/$1.html [NC,R=301,L] 但是这没有任何作用。 我尝试了URL和规则(用/replace?): http://myserver/blog/archive/openview&type=Category&key=Demo ^/blog/archive/openview&type=Category&key=(.*) /blog/categories/$1.html [NC,R=301,L] 而且这个按预期工作。 所以我有点笨拙如何处理? 用于匹配旧的url。 我发现的所有样本都描述了相反的情况。 发送“漂亮”的URL到丑陋的一个。 在我的情况下,“丑陋”的url是过去人们collections的url,我想确保他们正确地获得新的数据
是否有可能将所有*.domain.comredirect到我的domain.com ? 我一直在与正则expression式搞乱,但没有任何运气: $HTTP["host"] =~ ".*\.domain\.com" { url.redirect = ("^/(.*)" => "http://domain.com/$1") } $HTTP["host"] =~ “domain\.com" { server.document-root = "/var/www/servers/domain.com/awesomesite" accesslog.filename = "/var/www/logs/domain.com/access.log" server.errorlog = "/var/www/logs/domain.com/error.log" fastcgi.server = ( ".fcgi" => ( "main" => ( # Use host / port instead of socket for TCP fastcgi "bin-path" => "/var/www/servers/domain.com/awesomesite/domain.fcgi", "socket" => "/tmp/domain.sock", "check-local" => "disable", […]
尝试阻止一些使用fail2ban读取Apache访问日志的恶意机器人,并坚持设置正确的正则expression式。 我想在访问日志中匹配的行是: 5.10.83.65 – – [18/Mar/2014:09:06:38 +0400] "GET /catalog/product_compare/ ,,/form_key/QLZ6ZkIwX3FWqme3/ HTTP/1.1" 302 522 "-" " Mozilla/5.0 (compatible; AhrefsBot/5.0; +http://ahrefs.com/robot/)" 而我试图使用的简化正则expression式: failregex = ^<HOST>*(AhrefsBot) 但是无论我尝试什么都行不通。 在这里find这个职位是我试图实现badbots 这就是我最终做的,不用做一个大的名单就把他们全部封杀,如果这些单词匹配,就要冒着风险,因为这可能会阻止合法的访问者。 我使用ignoreregex来允许好的,并阻止其他机器人,只要他们自称为bot: failregex = ^<HOST> -.*compatible;.*(Bot|bot) ignoreregex = (Google|Yandex|Mail|bing) 现在这是远远不够理想的,但是阻止99%的不需要的扫描器机器人释放服务器,快速和肮脏。
我需要能够使用$request_uri顶级目录,例如: /dir/sub/slug – > /dir 我读了这个问题的答案: 如何从请求中提取只有文件名uri # Gets the basename of the original request map $request_uri $request_basename { ~/(?<captured_request_basename>[^/?]*)(?:\?|$) $captured_request_basename; } # Gets the basename of the current uri map $uri $basename { ~/(?<captured_basename>[^/]*)$ $captured_basename; } 它似乎与我所需要的接近,这是如何工作的? 是否有可能被修改,以获得顶部目录呢? 谢谢!
我正在尝试为fail2ban创build一个筛选器来识别UFW日志中的端口扫描。 我已经确认我的禁止行为在其他filter上正常工作,并且在这个场合创build正确的filter/正则expression式时遇到了困难 – 我相信这将成为我的一个愚蠢的错误。 我已经尝试了fail2ban-regex工具,并获得了0次。 我的jail.local包含: [ufw-port-scan] enabled = true port = all filter = ufw-port-scan banaction = ufw-action logpath = /var/log/ufw.log maxretry = 10 我试图创build的filter(位于/etc/fail2ban/filter.d/ufw-port-scan.conf )如下所示: [Definition] failregex = kernel: \[UFW BLOCK\] IN=.* SRC=<HOST> ignoreregex = 我正在尝试在ufw.log标识一个示例行: Sep 18 21:06:08 trial kernel: [ 3014.939702] [UFW BLOCK] IN=eth0 OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:00:00 SRC=192.168.0.5 DST=192.168.0.10 LEN=44 TOS=0x00 PREC=0x00 […]
我们知道如何通过mime_header_checks指令来拒绝可执行文件和其他潜在危险的文件扩展名: mime_header_checks = regexp:/etc/postfix/mime_header_checks (main.cf) /name=[^>]*\.(bat|com|exe|dll|vbs)/ REJECT (mime_header_checks) 这样bat,com,exe,dll,vbs都不见了。 但是,由于操作系统的处理像可执行文件的扩展文件,我想到这些也应该被阻止。 如何得到这个/什么是正则expression式来匹配这些文件以及已知的可执行文件?