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

0
votes
0answers
21 views

Using regex with several locations in nginx

I have dynamic number subfolders of the domain. For example: http://mysite/en/ http://mysite/en-us/ http://mysite/de/ http://mysite/ru/ In general, subfolders look like "en","de","ru" OR "en-us", ...
0
votes
1answer
43 views

apache - query string rewrite rule adds percentage symbol

I've set up a rule to rewrite a query string. Although the redirection is correctly performed, a % character is appended to the rewritten query portion of the URL, like so: ...
1
vote
1answer
30 views

Show real server name in nginx logs and params passed to fastcgi?

I have configured my nginx vhosts with a regex in server_name. nginx shows the raw regex in logs and in params passed to php-fpm (I know there's $_SERVER['HTTP_HOST'] with a real value, that's not an ...
1
vote
0answers
11 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
1answer
847 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
1k views

Nginx match multiple paths in location directive

I have the following directives in my nginx conf, that are working correctly: location = /favicon.ico { root /home/www/myapp/static/ico; } location ^~ /apple-touch-icon { root ...
-1
votes
2answers
32 views

Fail2Ban Regex - Joomla / PHP5-FPM

i can't get a regex for fail2ban to work. I want to match the following: [Tue Jun 24 10:22:14.528987 2014] [fcgid:warn] [pid 22526:tid 139757615011584] [client IP:PORT] mod_fcgid: stderr: user admin ...
0
votes
1answer
2k views

Nginx location regex is not matching

The following has been working to cache css and js for me: location ~ "^(.*)\.(min.)?(css|js)$" { expires max; } results: $ curl -I http://mysite.com/test.css HTTP/1.1 200 OK Server: nginx ...
0
votes
1answer
639 views

Is it possible to match more than one regular expression with a single <ProxyMatch> rule?

I have a production, testing, and development server for a site that I maintain. All three servers are running Apache 2.2.16 on Debian 6 GNU/Linux. I have set up a new version of our company site on ...
6
votes
2answers
987 views

Grepping for CIDR ranges

From time to time I want to grep CIDR ranges out of my Apache log files. This is easy for ranges that fall on the natural boundaries (/8, /16 and /24) but not so easy for other ranges such as /17 and ...
0
votes
1answer
24 views

Postfix Regex Alias with Text Substitution

I'm migrating from an older email structure ([first letter of first name].[last name]@company.com) to [first letter of first name][last name]@company.com. To ensure that mail sent to older addresses ...
0
votes
0answers
20 views

redirect robots.txt to alternative apache mod rewrite [duplicate]

I'm having trouble trying to get an alternative robots.txt to display for different host names so that Google or Bing won't spider different addresses. Here's what I have so far #temporary dev rule ...
0
votes
1answer
30 views

Puppet: Nagios with regex node names

I am configuring a puppet master and want to rely heavily on hiera. Many of my systems will be almost identical due to being scalable. I have therefore created node manifests which use regex rather ...
1
vote
2answers
104 views

nginx url rewriting. i just don't get it

Ok, an example url is http://www.mysite.com/?p=account&view=settings the p uri is a constant. all urls have it. the view is one of many optional uri. i've tried to understand url rewriting ...
0
votes
1answer
60 views

Optional URL segments in NGINX

I need to proxy pass multiple segments further to another server, there can be up two 5 segments. What nginx needs to match example.com/somehash example.com/somehash/segment1 ...
0
votes
2answers
109 views

Zabbix doesn't update value from file neither with log[] nor with vfs.file.regexp[] item

I am using Zabbix 2.2. I have a very specific environment, where I have to generate desired data to file via script, then upload that file to ftp from host and download it to Zabbix server from ftp. ...
1
vote
0answers
38 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"; } ...
2
votes
3answers
20k views

Most simple way of extracting substring in Unix shell?

What's the most simple way to extract substring on Unix shell (with regex)? Simple means: less feature less options less study Update I realized regex itself is conflicting with simplicity, and ...
1
vote
0answers
33 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" ...
0
votes
0answers
20 views

mod_pagespeed ModPagespeedLoadFromFile ReGex not working

I have following directive in MPS config: ModPagespeedLoadFromFile "^https?://www.(e|i)zi?aro(v|w)k(y|i).(cz|sk|pl)/static/" "/var/www/eZarovky/production/public/static/" This RegExp should match ...
2
votes
1answer
289 views

Apache LocationMatch regex behaviour does not seem correct

I am using the LocationMatch directive to set headers upon matching of certain URL patterns: # 1 # Expected matches: //mysite.com/any-page-with-at-least-a-character-and-no-dot <LocationMatch ...
0
votes
1answer
50 views

Nginx Extract Top Directory Name From Request URI

I am in the need of being able to use top directory from the $request_uri, for example: /dir/sub/slug -> /dir I read the answer of this question: How to extract Only the file name from the request ...
0
votes
1answer
137 views

Filter python messages with regex in syslog-ng

I have syslog-ng (v3.4.7) configured to catch almost all messages in their respective logs, but recently I've included some python scripts in crontab and their output just goes to messages or debug ...
1
vote
1answer
66 views

fail2ban-regex matches with strings, but not with log and conf files, why?

If I run fail2ban-regex '31.22.105.115 - - [11/Apr/2014:18:09:54 +0100] "GET /admin/config.php HTTP/1.0" 301 573 "-" "-"' '^<HOST> - - (?:\[[^]]*\] ...
1
vote
1answer
180 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: ...
1
vote
1answer
156 views

Nginx redirect all old domain subdomains to new one

I had a very long domain, so I decided to change it to a shorter and more friendly one. But since I have a lot of subdomains (in fact, I have a subdomain wildcard), I wanted to keep the subdomain ...
1
vote
1answer
285 views

fail2ban bad bots apache access log regex

Trying to block some bad bots using fail2ban reading Apache access log and stuck setting up correct regex. The line I want to match in the access log is: 5.10.83.65 - - [18/Mar/2014:09:06:38 +0400] ...
7
votes
4answers
1k views

Searching for literal “> \” using ack-grep

I am looking for lines that literally have a greater than character (a ">") followed by a space followed by a backslash character (a "\") i.e., a line with this: > \ I thought escaping would allow ...
0
votes
0answers
30 views

Issue with a NGINX Location regex

I'm just dealing with a location issue today, I have a customer domain with the following format: subdomain.domain.tld and urls as: subdomain.domain.tld/servicename I'm trying to forward this ...
1
vote
1answer
42 views

Postfix regexp map for mailboxes

I need to forward all email that comes to mailbox by some mask to one specific mailbox. For example if recipient mail is 79001234567 it should be forwarded. line from /etc/postfix/main.cf ...
1
vote
1answer
183 views

Redirect all subdomains to main domain with lighttpd and regex

Is it possible to redirect all *.domain.com to my domain.com? I have been messing around with the Regex but without any luck: $HTTP["host"] =~ ".*\.domain\.com" { url.redirect = ...
0
votes
2answers
553 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: ...
0
votes
0answers
33 views

Negative match for IP based RegEx

I am looking for negative matching for the below IP based regular expression: True-Client-Ip: ...
2
votes
0answers
36 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 ...
0
votes
2answers
322 views

Nginx RegEx to match a directory and file

I'm wondering if it's possible to match Wordpress directory and specific file in the same location, so at the moment I've got rule to match only the wp-admin directory: ## Restricted Access ...
0
votes
1answer
103 views

Sieve: filter subject with regex, file into mailbox named match

I am trying to filter mails by subject with a regular expression. The subjects I want to match are read like [git-foo] some more text where foo is the string I want to check for. I end up with the ...
1
vote
1answer
248 views

Apache RewriteCond: inject string into URI between regex match groups

EDIT This works, needed to use % in place of $ for capture groups: RewriteRule (.*) http://localhost:8081/%1/%{TIME_YEAR}1101%2 [P] Having a hard time sorting this out. Need a date string ...
0
votes
1answer
45 views

Invalidating email addresses from sql dump before import

Synopsis I would like to import production data into the development environment so testing can be done in an almost accurate way. Of course I need to invalidate e-mail addresses as I don't want ...
0
votes
1answer
35 views

Location regex acting weird on NGINX

I come to you today with a super strange comportment on my NGINX reverse proxy. I use it to be the reverse proxy of a tomcat server and set the host configuration like that: server { listen ...
0
votes
1answer
95 views

Using named groups in a DirectoryMatch directive

I have the following directive in my httpd.conf: <DirectoryMatch ^/path/(?P<SI>[^/]+)/logs/bibi> php_admin_value open_basedir /path/?P=<SI>/ </DirectoryMatch> The ...
1
vote
0answers
89 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 ...
0
votes
2answers
40 views

Tinydns data file change ip with bash

I am using tinydns and need to dynamicly change some ip in data file. I want to use bash script for it. For example data file: +sub1.example.org:282.196.222.245:14400 ...
0
votes
1answer
1k 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 ...
0
votes
1answer
122 views

Whitelisting valid URL patterns on a NGINX webserver

I want to whitelist only valid URL-patterns on our RESTful webserver / API, using regexs or something. But when googling for some examples I get a little bit suspicious since there is not much ...
0
votes
0answers
84 views

How to exclude a URL from mod-rewrite with nginx?

I'm moving my Joomla! 2.5 from Apache Ubuntu to Debian nginx and I need to exclude some URLs from the mod-rewrite. Now I'm rewrite all within this directive on the IspConfig panel: # mod_rewrite url ...
0
votes
2answers
2k views

Nginx: location regex for multiple paths with backend

I have two locations in nginx config that work: location ^~ /media/ { proxy_pass http://backend.example.com; } location ^~ /static/ { proxy_pass http://backend.example.com; } How can I combine ...
1
vote
1answer
31 views

Rewrite rule when source contains a '?' [duplicate]

Scratching my head on this. I have an old URL: http://myserver/blog/archive?openview&type=Category&key=Demo and a new URL http://myserver/blog/categories/Demo I'm trying to get ...
1
vote
1answer
133 views

How to make comments in logcheck files?

how can I add comments to logcheck ignore-rules? Things I tried so far: # seems to match single # characters instead of starting a comment empty lines matches against everything $ matches against ...
1
vote
0answers
43 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
1answer
75 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, ...