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)

3
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 "http://my.domain....
2
votes
1answer
88 views

htaccess regex not processing URLs properly

I'm trying to redirect (or 'rewrite') over 3000 urls for a site where we updated the SEF of most of the content pages to remove an ID number that was not needed/desired. This should be a simple ...
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: ...
2
votes
1answer
313 views

fail2ban jail not working properly

I'm trying to block non-available script requests to nginx with fail2ban. # Noscript filter /etc/fail2ban/filter.d/nginx-noscript.conf: # # Block IPs trying to execute scripts such as .php, .pl, ....
2
votes
1answer
560 views

Regexp in HAProxy's reqrep for asset management

I'm hosting assets on S3 with this kind of URL: http://cdn.site.com/image.jpg In my application I automatically serve versioned URL to force browser to download new files after the deployment: "/1.2.3/...
2
votes
1answer
212 views

Logcheck: wildcards which include non-latin characters

On my mail server, I have a custom logcheck rule as follows, which is intended to filter messages from deliver: ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ deliver\.*\): msgid=.*: saved mail to.*$ ...
1
vote
1answer
37 views

fail2ban: regex to block \x00 requests?

Every once in a while my server goes down, and when I check my nginx logs, I usually see something like this: 78.37.54.31 - - [20/Apr/2016:20:58:51 +0300] "\x00\x00\x00TZ\x00\x00\x00\x00\x00\x00\x00\...
1
vote
1answer
141 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 example....
1
vote
1answer
63 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 ...
3
votes
0answers
48 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: ...
2
votes
0answers
674 views

nginx subdirectory to subdomain icingaweb2

I currently have icinga2 set up with the new icingaweb2 ui. it defaults to the subfolder /icingaweb as follows: location ~ ^/icingaweb/index\.php(.*)$ { # fastcgi_pass 127.0.0.1:9000; ...
2
votes
0answers
70 views

php-fpm: Maintain php_mod logging format

I recently switched all my lab servers from apache pre_fork/mod_php to apache worker/fcgi/php-fpm, and after getting everything set-up correctly, I noticed one last issue; php-fpm is adding it's own ...
2
votes
0answers
90 views

Unable to match expression inside If directive no matter what

I have been trying for the past 3 hours trying to match an if statement to define a variable within httpd.conf with no success: <If "%{HTTP_HOST} =~ /[a-z]+/i"> Define test_value "A" </If&...
2
votes
0answers
53 views

List subfolders somewhere in the path with rsync

I'm developing a program, that will recursively "walk" through Linux repositories, look for PXE-related files and create gPXE configs. I met across a problem with the structure of Ubuntu catalogs on ...
1
vote
0answers
19 views

nginx and site.erb: tag as internal users for two different domains and two different sets of IPs

I have an nginx server and a site.erb file and two different domains (domain1 and domain2). Currently a tag (for Google Tag Manager) will be set when someone visits the sites from a particular set of ...
1
vote
0answers
16 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
vote
0answers
44 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 '...
1
vote
0answers
52 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
0answers
28 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 ...
1
vote
0answers
114 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. ...
1
vote
0answers
26 views

Apache rewrite not finding path

I am trying to rewrite an internal path for specific requests. I have the following URL: http://192.168.0.100/iw/cci/meta/no-injection/iw-mount/default/main/intranet/infozone/pab/WORKAREA/content/...
1
vote
0answers
66 views

rsyslog regex global modifier

Many regex systems have the ability to set a global modifier to allow for multiple matches. Here's how it works in Javascript and Perl. /g Python is a little different Python doesn’t have a ...
1
vote
0answers
50 views

Apache2 mod_rewrite, handling the optional “/” at the end of a URL

I am attempting to host a single custom page to set as my homepage on my server. The real path to the page is example.com/start.html. However, I do not want this ugly URL in my homepage so I am ...
1
vote
0answers
52 views

SED returning error 2 when launched by Wpkg

Case I am deploying a software product using Wpkg over Windows workstations. I need to disable product's faulty automatic update and the best solution in this case is to modify one configuration file ...
1
vote
0answers
232 views

varnish - multiple catch-all domain names

In order to avoid setting up one backed per subdomain, I am specifying a catch-all regex string per domain name, as follows: backend domain1 { .host = "10.10.10.5"; .port = "80"; } ...
1
vote
0answers
438 views

Exchange 2013 Mail flow rule using RegEx

We're trying to implement a rule on certain mailboxes that it shouldn't accept an email without a subject. I found documentation from Microsoft on exchange 2010 to Configure a Transport Rule for ...
1
vote
0answers
68 views

How to convert RewriteCond rules so they work in Lighttpd?

How can I convert this Apache rewrite rules so they work on Lighttpd? This is in fact a .htaccess file, and I need to put those in a lighttpd.conf file. Options +FollowSymLinks RewriteEngine on ...
1
vote
0answers
213 views

Nginx - Adding a trailing slash to urls on HTTPS

I am using the below regex to add a trailing slash to any url that doesn't have a railing slash or ends ends with .. rewrite ^([^.]*[^/])$ $1/ permanent; This works fine for http, but when I use ...
1
vote
0answers
293 views

Multi-line regex replacement in apache

I need to do multi-line replacement in apache2, an mod-substitute only does single line matching AFAIK. I need to be able to do something like this: replace <script> foo = x; bar = y; alert(x ...
1
vote
0answers
175 views

PHP UTF-8 bondary regex does not work

I have a CentOS 6 with newest updates running a LAMP stack. A user is complaining that his code does not work and he is trying to use preg_match with unicode characters. This is the code not ...
1
vote
0answers
640 views

Squid Random Shared ip proxy

Running Squid with a acl random ip setup, Have 745 ip's in the pool and we are about 10 users that use it with tools that are running multiple threads, Check rankings on Google etc Issue: We did ...
1
vote
0answers
615 views

Apache LocationMatch does not work for group

I would like to configure Apache to proxy mldonkey running at localhost. Initially I have used the following configuration (in server config): <IfModule mod_proxy.c> <LocationMatch /(...
0
votes
0answers
24 views

Fail2ban on CentOS, dovecot filters regex not matching logs

I'm starring at this regex for some time now and it seems perfectly matching lines from my log files but I can't get it to work, not even with modifications. I suspect the problem might be with the ...
0
votes
0answers
7 views

Odd regex behaviour matching newlines with s and m modifiers

I wish to remove a block of code from a file - along with any unnecessary newlines. Input file 'test' <block 1> nothing here </block> <block 2> foo bar </block> <block 3&...
0
votes
0answers
21 views

NGINX not recognizing $request

Well.. NGINX or me guess.. something that I'm not doing OK. The point is, I'm getting some request from bots of this type: 91.123.1.56 - - [04/Apr/2016:12:13:39 +0200] "V\x5CxA1po\x5CxA9^\x5Cx8F\...
0
votes
0answers
37 views

fail2ban regex correctly write

Sorry for my bad english. Server nginx. Block /administrator/ http_access_module nginx-error.log [error] 10934#0: *11435 access forbidden by rule, client: 213.87.x.x, server: localhost, request: "...
0
votes
0answers
58 views

Regex nginx location with named location

I have the following set up - a production version of some software; location @myradio { rewrite ^/myradio/([^/]+)/([^/]+)/? /myradio/index.php?module=$1&action=$2 last; rewrite ^/...
0
votes
0answers
29 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 ('name@...
0
votes
0answers
39 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 ^/(.*)/...
0
votes
0answers
18 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 ...
0
votes
0answers
69 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
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 old.com/some/place/?...
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 folders/...
0
votes
0answers
177 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
0answers
99 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 ...
0
votes
0answers
69 views

Removing query strings for a certain location

I am using nginx, and I want to remove query strings on a request in such a way that: With this code, it's not happening. I get a 404 on /store/name. /store/name?page=1 becomes /store/name location ...
0
votes
0answers
27 views

nginx rewrite url issue

Current rewrite URL : rewrite ^/link/(.*)/(.*)/(.*)/$ /link.php?one=$1&two=$2&three=$3 last; What I need is solution so three link samples work: 1) /link/one/ 2) /link/one/two/ 3) /...
0
votes
0answers
532 views

Graylog2 date extractor from tab-delimited file

I have a tab-delimited logs with such messages: 2014-06-01 00:00:56 192.168.1.1 968 http://yandex.ru I can extract date and time with regexp (\d{4}-\d{2}-\d{2}\s*\d{2}:\d{2}:\d{2}) but when I ...
0
votes
0answers
99 views

Negative match for IP based RegEx

I am looking for negative matching for the below IP based regular expression: True-Client-Ip: (25[0-5]|2[0-4][0-9]|[0-9]|[01]?[0-9][0-9]?).(25[0-5]|[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[...