When asking regex questions, always add the tag for the specific programming language or tool (e.g., Perl, Python, or Java; vi, emacs, or ɢɴᴜ grep; etc.) you are using.

learn more… | top users | synonyms (1)

0
votes
1answer
7 views

Implement apache equivalent mod_rewrite functionality in lighttpd

Here's the mod_rewrite .htaccess file which is meant to work on Apache Servers for my web-app RewriteEngine On RewriteBase /cs200/tokens/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond ...
2
votes
1answer
3k views

nginx return 301 / redirect

among all 'redirect in nginx' questions I couldnt find how to redirect (using return 301 and beteer no ifs) using regexps. I have a link to my website and I'd like to remove parameter a the end: ...
0
votes
1answer
23 views

.htaccess config not working properly

Here is my current situation: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d [NC] RewriteCond %{REQUEST_FILENAME} !-f [NC] #the rule RewriteRule ...
0
votes
1answer
19 views

Block specific URL in HAProxy / url-encoding

I'm trying to restrict access to a specific URL. It should not allowed to access /admin.php. frontend example acl restricted_page path_beg -i /admin\.php http-request deny if restricted_page ...
0
votes
1answer
12 views

Insert a variable route path into nginx location configuration

I have a simple user based storage for images where I have a main folder say 'users' and within it, my server creates variable folders to store images for each user. The string used for the folder is ...
0
votes
2answers
158 views

htaccess rule to rewrite %3F to ? and %3D to =

I need to rewrite the URL of my site which contains %3F to ? and %3D to = I have tried this rule: RewriteCond %{HTTP_HOST} myhostname RewriteRule ^(.*)%3F(.+)%3D(.+)$ $1?$2=$3 [L,R=301] ...
1
vote
1answer
61 views

Fail2Ban regex to match these lines?

I've been trying to get fail2ban to work with the Xeams email spam filter. But, I can't figure out what possible regex I should use to match the logs. The logs are in this format. 61.240.144.65 ...
0
votes
2answers
4k views

Zabbix 2.0: Regular Expression to extract value from a String for a trigger?

I am using Zabbix 2.0.4 to monitor several Java applications. Most values are exported via JMX. One of those exported attributes is a string that is constructed like this: ...
2
votes
1answer
2k views

nginx regex characters that require quoting?

So I was configuring nginx today and I hit a weird problem. I was trying to match a location like this: location ~ ^/([0-9]+)/(.*) { # do proxy redirects } ...for URLs like ...
0
votes
1answer
25 views

match special characters in url in nginx

I ran dotdotpwn to test transversal attacks on a web server using nginx/nasxi/doxsi and the only "successes" were urls that started with a question mark. No big deal since they just defaulted to the ...
0
votes
0answers
10 views

Regex in Exchange transport rule

We are receiving external emails with invalid characters in the emails address which is causing issues for applications linked to the mailboxes. The receipient addresses contain single quotes ...
0
votes
1answer
1k views

Nginx alias and regex

i'll need a bit of help for alias on folder with nginx I have my folder www/ with the container of my site example.com and a lot of folder like client0, client1, client2... I should NOT modify ...
0
votes
1answer
31 views

url rewrite, nginx throw 404 errors, nothing in error logs

below rewrite works fine: rewrite ^/city/restaurants$ /city/listings/restaurants permanent; but this doesnt work rewrite ^/city/restaurants$ /city/listings/restaurants last; rewrite ...
1
vote
0answers
12 views

URL rewrite is producing 404

I'm trying to rewrite office.domain.com/app1 requests to server3:81 using the rule below, but I'm getting a 404. I can browse to server3:81 just fine. The Failed Request Tracing logs are available ...
-1
votes
0answers
22 views

nginx: rewrite relative paths and exclude some paths

Here again the bloody regex: i want to rewrite from : /city/listings/restaurants to /city/restaurants *i.e: i want to remove listings from url* **** pls note "city" and "restaurants" always ...
0
votes
0answers
28 views

Redirect lang set in url with Nginx regex

I can't find the way to redirect the lang set in url with Nginx. I tried this: location ~ ^/(en|fr|de)/cloud/signup { return 301 $scheme://cloud.$host/$1/home/new; } Also this: location ...
1
vote
2answers
33 views

Exim: match recipient address against certain regex and conditional email delivery

I need to allow my customers to use e-mails in format of 4ca2bc00-6789-4161-bae7-c11c5b91454e@example.com, where the username part is sort of UUID. Those emails should be delivered to certain (single) ...
3
votes
0answers
24 views

Regex location block not working in NGINX

I have a pretty simple location block in my nginx conf that looks like this: location ~* ^\/[a-z0-9]{24}$ { // do some things } I'm attempting to catch urls that end in a Mongo ObjectId. eg: ...
3
votes
1answer
40 views

ubuntu 14.04 Apache 2.4.7 mpm_event Files and FilesMatch not working

We recently switched our Apache 2.4.7 mode from mpm_pre-fork to mpm_event. Since then we haven't been able to get our Files directive to work. <Files "*.php"> Header set Cache-Control ...
0
votes
0answers
10 views

Apache ProxyPass rules to stop at first match [duplicate]

I want to stop ProxyPass rules to stop executing at first match. I've given some rewrite rules in the end. So Rewriterules are getting executed all the time. Below is the two lines, i want to work ...
0
votes
4answers
2k views

Nginx add trailing slash without rewrite

I am trying to create redirect to add trailing slash, location / { if($request_uri ~ ^([^.]*[^/])$){ return 301 https://$host$request_uri/; } } I have no idea how to do matching in if, ...
1
vote
1answer
44 views

How to parse s3 logs?

I've been trying to parse AWS S3 logs following the documentation, but I've been running into some problems. Specifically, I keep running into new, rare log lines that break my regex. Every time this ...
1
vote
1answer
81 views

Is fail2ban not matching these lines just because of the port?

I would like fail2ban to engage against these lines and block the example IP address included: [Tue Dec 08 12:17:13.622175 2015] [:error] [pid 30390] [client 62.210.88.201:38139] script ...
0
votes
0answers
15 views

Nginx: redirect from some-site-username.server to some.site.username.server

Can you help me pls: need configure Nginx that he made next: when we go to some-site-username.server he redirect us to some.site.username.server Main problem - on the server many users, so I can't ...
1
vote
0answers
17 views

How do I set Host Groups on Fail2ban for Wordpress?

I'm trying to set up a custom filter for fail2ban on a wordpress site. I've been following this tutorial but when I try to test my custom filter, I get the error: server.failregex.RegexException: No ...
0
votes
2answers
39 views

.htaccess rule to 301 redirect /?my_foo=bar to /foo/bar/

I tried, unsuccessfully, for hours to build (what I think is) a simple 301 redirect in an htaccess file. My url looks like this: www.example.com/?my_foo=bar And I want it to 301 redirect to: ...
0
votes
2answers
77 views

Prepend String using perl/awk/sed?

I'm trying to script a change to my apache config file (httpd.conf). I'm trying to match the following string: # # DirectoryIndex: sets the file that Apache will serve if a directory And PREPEND ...
1
vote
2answers
6k views

How do I match a wildcard host in ACL lists in HAproxy?

I have the following lines in my haproxy.conf: acl valid_domains hdr(Host) -i mysite.com images.mysite.com docs.mysite.com admin.mysite.com redirect location http://mysite.com/invalid_domain if ...
1
vote
1answer
78 views

Nginx Config Location Regex With Language Code In Url

Trying to achieve constant language code in url's 1st segment with nginx regex location configuration and could not find the correct syntax. Necessary result: example.com stays example.com ...
5
votes
5answers
859 views

Globally Coloring the Terminal by Regex

I know many programs use color - (vim, ack, color-ls to name a few) but there are still many cases where you're stuck with black and white. There are scripts that will color output based on regular ...
1
vote
0answers
45 views

How to modify the message string being logged by syslog?

I have a few linux systems with the keyboard and console shared via a KVM switch. When I switch between them, I get a lot of unwanted syslog messages regarding the keyboard connecting and ...
1
vote
1answer
24 views

Redirect page to 410 if match a specific Regex in .htacces

First time using .htaccess so I come here to have a bit of help since the web is not that file with informations (or I just don't find them :/). So the idea is that I want to redirect link ending by ...
1
vote
1answer
156 views

Apache HTTP LocationMatch Redirect using Negative RegEx

I'm trying to create a Redirect using Apache HTTP Server's mod_alias and core on my system: # cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.1 (Maipo) # rpm -q httpd ...
1
vote
1answer
26 views

rabbitmqctl set_policy drops caret (^) anchor from regex pattern

I am running this from PowerShell, so I'm not sure if this would happen in a different environment (the regex itself just includes everything except for those starting with 'amq.'). When I run the ...
0
votes
0answers
66 views

Rewrite /a/1/2 to /a.php using Nginx

I'm taking over a really old app and migrating it from apache to nginx. What I currently have. This works: # catch specific paths, rewrite to first segment # /a/1/2 => a.php # /b/3/4 => b.php ...
0
votes
1answer
23 views

Unable to use grep regex to search for filename containing period

Ubuntu 14.x. Using grep to search for all files linuxtest-client2. This includes multiple file extensions (csr, crt, key). When I grep for the middle portion of the filename, "2.", it also returns ...
1
vote
0answers
25 views

nginx, redirect to remove a part of filename

I know there are plenty of questions how to replace part of URL with something else (or nothing) in nginx but I really suck in regular expressions and am absolute noob in nginx. So could anybody ...
0
votes
1answer
69 views

Determining e-mail server blacklisting from log files

I have my self-hosted e-mail server. There is no current problem of being blacklisted but I want to be proactive about it and I want to start with the log files. There have been some entries in my ...
1
vote
1answer
172 views

Reg Exp for URL in HAProxy

I'm trying to build a reg exp for haproxy that will match the second URL and direct it to a different acl than the first: mysite.com/path/ mysite.com/path/something_random The issue is that my ...
0
votes
3answers
64 views

exim: redirect all but a number of local parts

On my server, I implement redirects using this router virtual_aliases: driver = redirect allow_defer allow_fail data = ${lookup{$local_part@$domain}wildlsearch*@{/etc/vhosts/forwards}} ...
0
votes
1answer
61 views

Nginx regex to get uri minus location

I have Nginx running as a reverse proxy to a couple applications. One location directive is running correctly, sending requests to a unix socket file and onwards to its upstream wsgi app. The ...
0
votes
1answer
76 views

Fail2ban: regex test succeed but fail2ban does not ban any IP

I can't ban any ip, thought when I test my regex, it has +2000matches: > fail2ban-regex '/var/log/nginx/access.log' '/etc/fail2ban/filter.d/bad-request.conf' Date template hits: |- [# of hits] ...
0
votes
0answers
11 views

Redirection regex rule not working for ? character

I know this is probably basic but what am I missing here? I want all urls from an old domain to 301 to the homepage of the new site. So: old.com/some/thing old.com/file.php ...
0
votes
1answer
67 views

Configuring IIS rewrite module to redirect any host name to a specific host name

I have a website whose name I am changing from example.com to newexample.com. My thought process (please comment on this as well, as my approach may be incorrect) was to configure permanent a ...
0
votes
1answer
23 views

nginx regex rewrite rule for images

I have the following URLs: www.example.com/data/images/13122013-002_IM1621.jpg www.example.com/data/images/13122013-002_IM1622.jpg www.example.com/data/images/13122013-002_IM1622.jpg On the file ...
1
vote
1answer
146 views

fail2ban regex filter doesnt work with nginx log files

I have been banging my head all day trying to match my regex filter to my access.log with no luck. I have installed fail2ban on a gentoo server and its running fine (i manually baned my own IP and it ...
0
votes
1answer
138 views

systemd logcheck rule not working

given is this logcheck rule: ^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ systemd-logind\[[[:digit:]]+\]: New session [[:digit:]]+ of user [^[:space:]]+\.$ and this log entry: Mar 19 09:16:09 horst ...
1
vote
0answers
85 views

Fail2Ban regex in sshd.conf not catching failed root logins in /var/log/auth.log

I used Fail2Ban on my Ubuntu server (14.04 LTS), and it mostly works well. I recently noticed the default regex in /etc/fail2ban/filter.d/sshd.conf does not match some failed sshd login attempts. ...
5
votes
2answers
897 views

Is it possible to get the matched regex from within the apache LocationMatch directive?

I'm wondering if the following code should be working: <LocationMatch "/(.*)([/])?(.*)"> Order allow,deny Allow from all AuthType Basic AuthName "Git" AuthUserFile ...
0
votes
3answers
50 views

Nginx rewrite and proxying

I am trying to combine these 2 Nginx location definitions into 1 location /v1/login { proxy_pass http://upstream/v1/login; proxy_redirect off; proxy_set_header Host ...