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
11 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
1answer
19 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
9 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
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
11 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
19 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
25 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
30 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
23 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: ...
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 ...
1
vote
1answer
55 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 ...
3
votes
1answer
37 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 ...
1
vote
1answer
80 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
16 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
38 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
73 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
1answer
73 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 ...
1
vote
1answer
42 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
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
22 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
138 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 ...
0
votes
0answers
65 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
22 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
67 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
155 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 ...
1
vote
1answer
25 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
1answer
57 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
74 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
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
143 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
65 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 ...
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. ...
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 ...
0
votes
1answer
39 views

Nginx - Deny folder, except subfolders with regex

I want to deny access to anything in the app directory, except in subfolders with an Assets folder. For example: Allow these files /app/bundles/ApiBundle/Assets/css/Thing.js ...
1
vote
3answers
106 views

How execute perl one-liner from perl script (properly escaped)

I have a perl script from within which I need to execute a simple perl one-liner on a remote host: ssh 192.168.1.1 "perl -pi.bup -e 's/^(\s+?kernel)(.*)(?<!audit=1)$/$1$2 audit=1/' /etc/grub.conf" ...
1
vote
1answer
21 views

nginx rewrite regex to add / to URL's ignores .pdf requests and adds /

On our server we have added rewrite ^(.*[^/])$ $1/ permanent;to add a / at the end of requested URL's and it works great, however its my understanding that the above regex adds a '/' if the URL does ...
0
votes
1answer
59 views

nginx “starts with” regex

I'm trying to block/allow access to a particular vhost based on string matching of the HTTP user agent name. The version number of the application in the HTTP user agent changes, e.g. ...
0
votes
0answers
11 views

IIS Url Rewrite Rule with Conditions Not Triggering

I am having trouble with using conditions in an IIS Url Rewrite rule. I want to perform the following logic: Match any request for a URL that: begins with "tools/" does not match specific ...
0
votes
1answer
289 views

How to check if LocationMatch regex is working?

I have location match regex ScriptAlias /script /var/www/somescript.bash Action some-handler /script virtual <LocationMatch "/(?:\w+:)?\/\/[^\/]+([^?#]+)/"> SetHandler some-handler ...
0
votes
0answers
72 views

nginx naxsi $URL_X doesn't work

Recently recompiled my NGINX with a NAXSI module. Now setting up the white lists but the $URL_X functionality doesn't seem to work at all. Generating Incorrect line BasicRule wl:1312 in NGINX ...
0
votes
2answers
147 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
votes
2answers
36 views

Regex - match third number before a character [closed]

I have this string: /dev/sda1 23G 46G 47G 22% And want to match only the integer in 47's place. I tried modifying the "match second set of numbers" example (i.e.,\d+[^\d*](\d+)) here to ...
-2
votes
2answers
113 views

how to replace one url with another using sed inplace replace in multiple files?

As you can see in the script example down there, I'm trying to find and replace (inplace replace) a string which is part of an URL with another string (url part) within ALL files found with that ...
1
vote
0answers
23 views

Apache rewrite not finding path

I am trying to rewrite an internal path for specific requests. I have the following URL: ...
0
votes
0answers
123 views

Remove .php extension only in certain directory - web.config

I'm having trouble making the pattern for matching the urls in a certain directory. I want to redirect users from mysite.com/posts/some-post.php to mysite.com/posts/some-post meaning that I want to ...
0
votes
1answer
81 views

puppet node name with regex

I am running puppet 3.7.3 on a windows 8.1 client and it is pulling in my default node definition. I am trying to create a more generalized definition by using regex on a group of nodes. Our naming ...
0
votes
0answers
58 views

Nginx return status code from regex grouping

How can I have nginx return a status code from a regular express match? location ~* "^/([\d]{3})" { return $1; } Returns an error 'invalid return code "$1"' I'm trying to setup a test ...