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)

2
votes
1answer
29 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 ...
0
votes
1answer
26 views

nginx config - replace/rewrite all dead links on a page. Add prefix to the uri

I want to inject "project name" to every link on a web page. Example: link and site http://localhost/osqa/ is working, but when I'm on the osqa page, all links are directing to localhost directly ...
0
votes
1answer
28 views

nginx - regex captures for multiple locations

Creating regex captures for multiple locations. Tree structure: /home/user/webapps/ ├── index.html <= content: root. ├── osqa │ ├── index.html <= content: osqa test A. │ ...
0
votes
1answer
25 views

Regex for multiple sshd Received disconnect from … [preauth]

What fail2ban regex would catch logs like these? Apr 9 08:48:28 server sshd[1856]: Received disconnect from 43.255.190.117: 11: [preauth] Apr 9 09:06:05 server sshd[1936]: Received disconnect ...
0
votes
2answers
31 views

nginx: regex not matching URI

i have this URI /orls/myservice/f?p=4550 and the following location location ~ "^/(.+)/myservice/f?p=(.+)$" { ..... } nginx is returning a 404 not found. the problem might come from the ? so i ...
0
votes
1answer
36 views

Nginx: location regex not working

i'm getting trouble with my regex don't know what is wrong with it. it's returning a URi with orls/f instead of orls/f?p=4550. When i pass https://secure.toto02.com/orls/myservice/f?p=4550 my conf ...
2
votes
3answers
77 views

Regex Replace Append Filename

How can I append characters to a files name in linux, using a regex? I've seen these two posts http://stackoverflow.com/questions/6985873/change-names-of-multiple-files-linux How to rename multiple ...
0
votes
3answers
61 views

Is there an option in Apache to check PHP files for malicious code before parsing them?

Basically, I would like Apache to check PHP files for certain patterns before parsing them. If these PHP files match the patterns, I would like to send something else in replacement back to the user. ...
0
votes
1answer
52 views

why Apache's setEnvIf doesn't set correct header and how to debug it

I have the following in my .htaccess file: <IfModule mod_headers.c> SetEnvIf Origin "http(s)?:\/\/(www\.)?(inreado\.local|testenv\.inreado\.com|inreado\.com)$" AccessControlAllowOrigin=$0$1 ...
1
vote
1answer
32 views

nginx regex location not matching

I have the below location below, which is among a larger conf file. As reference, this works: location = /scripts/news/admin/index.js { alias /my/file/path/news/scripts/admin/index.js; } ...
0
votes
0answers
72 views

nginx error log Grok pattern

I am having trouble getting the following nginx error log message to parse in the grok debugger. I have a feeling there is a stupid trick that I should use but can't figure out what it may be. ...
0
votes
0answers
29 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
15 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
1answer
67 views

postfix header_checks - regex spanning multiple lines

I would like to create a spam filter that spans multiple lines in headers. This is my /etc/postfix/header_checks file: /^From:.*name[0-9]+@.+[\r\n]+To:.*name@domain\.com/ REJECT It's a valid ...
1
vote
1answer
73 views

Block attachment files without extensions in Postfix via mime_header_checks?

We know how to reject executables and other potentially dangerous file extensions via mime_header_checks directive: mime_header_checks = regexp:/etc/postfix/mime_header_checks (main.cf) ...
0
votes
1answer
51 views

Nginx - redirecting non-www to www, but not subdomains

I have many domains linked to the same php directory, and I need all of them to redirect from non-www,non-https to www,https. # Add www, if missing server { server_name ...
0
votes
1answer
29 views

Proxy action for user-agent blocking with regular expressions not blocking

I have a server behind a Watchguard XTM firewall and want to block incoming RESTClients who has certain user-agents in their request headers. I have implemented several rules to do this: List image ...
0
votes
0answers
28 views

Regex based Transport rule is too aggressive

I am trying to create a transport rule in Exchange 2010 to filter credit card numbers. Regex support for transport rules is limited as per TechNet. The output from Get-TransportRule "credit card ...
0
votes
1answer
25 views

Nginx Rewite - Matching End Urls not working

Trying to redirect urls like these: http://example.com/vehicles/cars/author/xyz http://example.com/plane/author/xyz to these: http://example.com/profile/xyz I tried this Nginx Rewrite, but its ...
0
votes
1answer
47 views

Manage several sub domains with nginx

I like to handle different sub domains in my Nginx server, this is my config file (partially) server { listen 80 default_server; listen ...
0
votes
0answers
60 views

Apache: Regex to log only last IP in X-Forwarded-For

I'm attempting to set up Apache 2.2's logging to record the last IP passed to it by the X-Forwarded-For header. I want to record the last IP from the X-Forwarded-For header if it exists and the ...
0
votes
1answer
94 views

sudo : wildcard in user/group name

I try to find a solution about a sudo problem. I need to push different sudoers files on different servers, depending on the users present on the servers. But I would like to know if I can avoid that ...
0
votes
0answers
52 views

Finding and renaming directories by regex in linux

I'm trying to match (and later rename) directory names like: A0000 (SOME-NAME) A0001 (SOME-OTHER-NAME) A0001 (ANOTHER-NAME) I'm testing to see if I match any using the find command but doesn't seem ...
2
votes
0answers
194 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; ...
0
votes
0answers
43 views

Fail2ban apache-myadmin regex

I've got a jail set up with the following regex, which I took from a standard filter file: apache-myadmin.conf failregex = ^[[]client <HOST>[]] File does not exist: *myadmin* *\s*$ ...
0
votes
1answer
81 views

Fail2Ban: I'm having trouble creating a regex for my Dovecot filter

I am trying to create a regex filter for my failed Dovecot entries in the maillog file. What I have created is: .*dovecot: auth: sql\(.*,<HOST>\): Password mismatch The target line in the ...
0
votes
1answer
58 views

nginx location regex /yyyy/mm/dd/

I'm trying to pass requests from address example.com/donor/2014/12/07/Name on the other server. URIs are like /donor/2014/12/07/Mike and I need to convert them to a query type of: ...
1
vote
2answers
723 views

Nginx location regex doesn't work with proxy pass

I'm trying to get these 2 location directives working in Nginx but I'm getting some errors back when booting Nginx. location ~ ^/smx/(test|production) { proxy_pass ...
1
vote
0answers
33 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 ...
0
votes
1answer
208 views

Postfix body_checks regexp expression does not work?

I have a a reject rule inside body_checks parameter written like this: /(\d{3,4},\d{2} EUR)/ REJECT Body Spam Rule 934 This regexp paramater should be ok, at least according to some testing pages ...
12
votes
1answer
149 views

How do I make sec ignore a timestamp properly

I have a rule that is set up like so; In /etc/sec/rules.d I have; type=SingleWithSuppress ptype=regexp pattern=(\S+) sshd\[\d+\]: PAM \d+ more authentication failures\; logname=.* uid=.* euid=.* ...
0
votes
1answer
141 views

nginx location regex match everything but home

I am trying to restrict access to everything but home "/". I mean: allow people to access example.com but restrict access with password to any other path: example.com/any-other-path. I have tried ...
0
votes
1answer
160 views

Writing a fail2ban multiline regex

I've got some troublesome hosts trying it on with an SSH server I run, and I'm trying to ban them using fail2ban. Problem is, I haven't done much work with regexes, and even less with Python regexes. ...
0
votes
1answer
82 views

Apache 2.4 AliasMatch NotWorking

I used to Alias have as below for /CollabPortal14300 which was working fine Alias /CollabPortal14300 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/ Alias ...
0
votes
0answers
131 views

How to update multiple registry key values using regex?

I am looking for a way to use regex in reg add command in order to update multiple registry key values. Is there any way to do this? reg add "HKEY_USERS\.DEFAULTS\Control Panel\Desktop" /v ...
0
votes
1answer
167 views

How to remove language part of $uri for purpose of try_files in nginx 1.6?

I have a site with language prefixes in $uri, for example: http://www.example.com/en/some/content http://www.example.com/ru/novost Sadly, due to limitations of framework I'm using, files are also ...
0
votes
1answer
26 views

Varnish 3 ignore the req.backend directive

Varnish3 is ignoring the req.backend directive. As explained on the documentation (here), I've set two backends, and the regex for redirecting the request to the correct one. By the way, seems liks ...
0
votes
0answers
62 views

Regex validation : simple hotlink prevention while allowing search engines (and their localized versions)

I made and tested a simple hotlink prevention .htaccess and wanted to validate it here before putting it in production. <IfModule mod_setenvif.c> SetEnvIf Referer mysite\.com|localhost ...
0
votes
0answers
53 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 ...
1
vote
1answer
295 views

Trouble with Fail2Ban UFW Portscan Filter

I'm trying to create a filter for fail2ban that recognises port scans in the UFW logs. I've confirmed my ban action is working correctly on other filters and am having trouble creating the correct ...
0
votes
0answers
9 views

mod_rewrite: Use Substitution from Previous Condition

I'm trying to do a basic language redirect based on a cookie. To do that and prevent a loop, I need to check that the user isn't already on the correct URL, so I wrote this rule: RewriteCond ...
1
vote
1answer
76 views

Regex matching first word and any word

I have a log file with a list of many entries. With grep regex I want to match the first word and another word which can be anywhere in the string. For example, if I specified "user1" the search ...
0
votes
1answer
76 views

nginx regex configuration for 404 images

I have dynamic link series like below; http://example.com/users/1871233/18712443_cover.jpg Only static thing is on that link is example.com/users and _cover.I want to make that ; when requested is ...
2
votes
2answers
332 views

nginx rewrite regex for API versioning

What I want is for the first to be turned into the second.. /widget => /widget/index.php /widget/ => /widget/index.php /widget?act=list => ...
-2
votes
1answer
79 views

zsh substitution, can't do regex with repetition

I'm trying to perform ZSH variable substitution, but I'm having to do it the lame way, by piping through cut. Is it possible to perform this operation entirely within ZSH? ...
0
votes
0answers
223 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 ...
1
vote
1answer
182 views

Nagios plugin check_snmp_int does not match regular expression

I am using nagios plugin check_snmp_int with -n switch. Help show: -n, --name=NAME Name in description OID (eth0, ppp0 ...). This is treated as a regexp : -n eth will match eth0,eth1,... ...
0
votes
1answer
94 views

Matching %ff in Nginx rewrite rules

I have some dubious requests coming into my server that contain %ff and %FF (e.g., /blog/%ffupdates/. I'm getting thousands of these daily and would like to start redirecting them to a 403. I ...
0
votes
2answers
96 views

How to print regex match

My problme is two fold. First is printing a regex match. The second is the actual regex. Problem 1: I'm trying to print the output of yum grouplist --verbose into a format that I can put into a ...
0
votes
2answers
2k views

apache - query string rewrite rule appends condition to URL

In trying to rewrite site-search.html?searchword=search%20term as advanced-search#q=search%20term I always end up with advanced-search#q=%3Fsearchword%3search%20term The %3Fsearchword%3 ...