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
31 views

Nginx rewrite, removing image dimensions from filename

For instance, if a request is made to an image like so... /static/images/00f37ac6291bb6e8_150.jpeg But the 150px thumbnail version hasn't been generated yet and returns a 404, I would like to have ...
0
votes
2answers
99 views

Nginx add trailing slash without rewrite

I am trying to create redirect to add trailing slash, location / { if($request_uri ~ ^([^.]*[^/])$){ return 301 https://$host$request_uri/; } } I have no idea how to do ...
0
votes
2answers
21 views

exim: redirect all but a number of local parts

On my server, I implement redirects using this router virtual_aliases: driver = redirect allow_defer allow_fail data = ${lookup{$local_part@$domain}wildlsearch*@{/etc/vhosts/forwards}} ...
0
votes
0answers
9 views

Apache rewrite to tidy up image urls [duplicate]

I am using the htaccess file that ships with the skeleton application for Zend Framework 2. Here it is: Options -Indexes RewriteEngine On # The following rule tells Apache that if the requested ...
0
votes
1answer
45 views

Modify fail2ban failregex to match failed public key authentications via ssh

fail2ban doesn't recognize failed public key ssh logins and I assume that this can be solved by modifying the failregex of /etc/fail2ban/filter.d/sshd.config to match the following line: <date> ...
2
votes
1answer
38 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
81 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
76 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
138 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
51 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
39 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
95 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
67 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
134 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
63 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; } ...
2
votes
1answer
267 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
47 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
17 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
98 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
111 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
95 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
43 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
41 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
30 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
52 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
74 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
126 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
60 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
233 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
50 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
88 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
63 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: ...
2
votes
3answers
1k 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
36 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
282 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 ...
13
votes
1answer
164 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
228 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
209 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
96 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
136 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
212 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
28 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
65 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
54 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
346 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
10 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
77 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
86 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
371 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
90 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? ...