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
1answer
28 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 ...
1
vote
1answer
16 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> - - (?:\[[^]]*\] ...
0
votes
1answer
22 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 ...
0
votes
1answer
49 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
69 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
67 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] ...
0
votes
0answers
15 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
26 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
48 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
146 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
23 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
21 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
1answer
30 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 ...
0
votes
1answer
34 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
36 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
58 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
27 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
54 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
1answer
21 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
265 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
0answers
36 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
305 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
26 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
0answers
35 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
56 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, ...
0
votes
0answers
37 views

Postfix bad notify parameter syntax

Please bear with me as I'm not an expert admin I have a linux mail server that has been running for a couple of years and now all of a sudden a certain user is unable to send emails. They immediately ...
0
votes
2answers
50 views

How do I get check_http -r to look for exactly n instances of a string

I have an URL I can query to make sure that my app is running properly. The results are something like below. Checking that "ok" is in the string does not tell me all is well, I need to know that it ...
0
votes
1answer
110 views

Ngnix Rewrite - If URL contains

I'm having a small issue - my error log is filling up with requests to a directory folder on my site (but with added data that shouldn't be there). http://example.com/the-directory/undefined ...
0
votes
1answer
58 views

NGiNX and MediaWiki rewrite regular expression

I am having some problems with regular-expression with rewrite in NGiNX. Here is my config: location /wiki/ { rewrite ^/([^?]*)/([^?]*)(?:\?(.*))? /$1/index.php?title=$2&$3 last; ...
0
votes
1answer
45 views

Lighttpd, regex in conf, path including regex match

The background : - Lighttpd 1.4.28 - Debian 6.0.7 i686 Several developers are using this web server, and each of them has his own virtual host named after "username.mysite.tld". These hosts are ...
0
votes
0answers
100 views

How to use regexp in haproxy?

I know haproxy can use PCRE (enable USE_PCRE and USE_STATIC_PCRE) or POSIX regexp, and POSIX regexp include BRE (Basic Regular Expression) and ERE (Extended Regular Express). If i install haproxy ...
1
vote
1answer
58 views

Wrangling sed to find and reformat login date (or, how to kill idle mosh-server processes)

I have an old method of killing idle mosh-server processes, which doesn't work on my new VPS. Here's the old method, which I run in root's crontab to clean up mosh processes that have been idle for ...
0
votes
0answers
22 views

Apache 2 rewrite rule expression [duplicate]

I need to make a rewrite rule in an intranet Apache2 (CentOS 6.4) Server. I need to redirect (servername)/(path) to (servername).(domain)/(path) OR (serverIP)/(path) to ...
1
vote
1answer
49 views

Use of backreferences in fail2ban filters possible?

From time to time, I see collections of suspect "File not found" errors in my Apache logs, basically using the pattern File does not exist: /var/www/file, referer: http://my.server.com/file In ...
1
vote
0answers
61 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 ...
0
votes
3answers
220 views

htaccess filesMatch exclusion

I have the following directive in my htaccess <filesMatch "\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml|html?)$"> FileETag None <ifModule mod_headers.c> Header unset ...
0
votes
1answer
142 views

nginx dynamic servername with regular expression doesn't work for co.uk

I'm trying to setup a nginx server which dynamically loads content from a folder for a domain. To do this I'm using regular expressions in the server name like so: server_name ...
0
votes
1answer
134 views

nginx rewrite rules with regex applied to one subdirectory only

I've been frustrated for days trying to figure this out, so any advice/help would be greatly appreciated! I've recently added a section called /links to a site at somehost.com but can't seem to get ...
0
votes
0answers
37 views

htaccess Rewrite leading zero in url causing trouble

I have a database with a string column made up of four unique digits attached to each record. I know this isn't the best way to do this but I'm kind of stuck with it. I'm trying to rewrite urls from ...
0
votes
1answer
53 views

serve a static file in nginx based on domain extension.ltd?

I was wondering and already did some extensive searches on how to serve a static file based on the domain.LTD extension. Nginx.conf: error_page 502 /maintenance.html; location = /maintenance.html { ...
0
votes
1answer
98 views

NGINX Drupal Redirect for Mobile

What I want to do; I want mobile users to be redirected to http://m.site.org/mobile-home. Being redirected to the m.bzaeds.org isn't an issue. I also have this working fine in Apache, but the same ...
0
votes
1answer
59 views

lighttpd Regex for automatic forwarding of subdomains

I have been looking round and I have not found a good way to automatically set the document root for domains automatically. For example: In the DNS, *.mydomain.com points to mydomain.com And in the ...
1
vote
1answer
120 views

nginx + regex, remove all parts of URI except the last one

With an URI like /a-part/some-part/another-part/last-part/?some_param=some_value how do I go about removing everything up to the last part with params and ultimately rewrite it to look like ...
0
votes
1answer
782 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
vote
1answer
90 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 ...
8
votes
1answer
162 views

Is there a tool that can top-ify an input stream?

I come across quite a few use cases where it would be very useful to take input from a (usually newline-delimited) stream and summarise it in a top-like fashion (see top, iotop, etc). A kind of ...
0
votes
1answer
136 views

Postfix regex for smtpd_command_filter

Some of my users are using Gmail to send mail to our domain (The mail server for which is hosted on a CentOS 5 machine with postfix). Sometimes, but not all the time, when they do, they get a ...
1
vote
1answer
49 views

Problematic Mail Sieve rules

I need top classify my incomming emails using this three rules: if the email was send to any @somedomain.tld, then copy that email to "somedomain_tld" if the email was send to any other @*.tld , ...
1
vote
0answers
55 views

Nginx reverse proxy using a hashed part of the url

to optimize local caching, I would like nginx to loadbalance requests based on only a part of the URL. For example: a) www.example.com/a/123123/b b) www.example.com/a/123123/c/d c) ...
4
votes
1answer
86 views

Apache MatchRedirect exception regex

I want to redirect any URL that is Https and hasn't start with "system_" to the same URL with http. for exapmle for this url : https://exsite.tld/some/thing/that/not/start/with/pattern to : ...