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)

-1
votes
0answers
17 views

Multiple regex statements to match

How can I manage email headers to reject all emails from specific email domain with specific filetypes? For example. If @gmail.com and filetype is .exe then reject. if /name=.*.exe/ if ...
0
votes
0answers
8 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
1answer
15 views

puppet node name with regex

I am running puppet 3.7.3 on a windows 8.1 client and it is pulling in my default node definition. I am trying to create a more generalized definition by using regex on a group of nodes. Our naming ...
0
votes
0answers
11 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
15 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 ...
-1
votes
0answers
22 views

Nginx and Regex: Can it do what I want?

Consider the following request string: http://<website>/<LotsOfOtherInformation>;SetCamera:Camera5-SetText:TextField1:$sometextinput$-SetText:TextField2:$somedifferenttextinput$ There's ...
1
vote
1answer
35 views

NGINX: Rewrite numeric URL segment with prefix

I'm aiming to have some old URLs work with the new CMS we're migrating to, but it can't support purely numerical URL slugs for some reason, so the new system has them as "/calendar/event/old-42" ...
1
vote
1answer
29 views

Determine if an e-mail contains a certain number of a specific character

I am hoping to write a SpamAssassin rule that will match if an e-mail contains over n of a specific character in the body of the message. Not necessarily continuous. So for example, if there were ...
1
vote
1answer
40 views

Command substitution into bash script $1 value

I have this simple script which changes permissions on my apache2 websites /var/www/html# cat permissions_setup.sh chown -R root $1 chgrp -R www-data $1 chmod -R 750 $1 chmod g+s $1 I have two .sh ...
0
votes
0answers
15 views

How to pass parameter when using apache mod headers SetEnvIf

I'm new to apache proxy regex - mod_headers and would like to know the following I'm trying to Set and Environmental if the value field of a Request header 'Referer' matches like this: SetEnvIf ...
0
votes
2answers
65 views

NGINX Proxy_Pass remove url substring

I have one NGINX acting as reverse proxy. I need to remove a substring string_1 from the URL, the rest of the URL is variable. Example: Origin: http://host:port/string_1/string_X/command?xxxxx ...
0
votes
1answer
9 views

Failure htaccess regax

I'm trying to get all request to the server to go to the index.php file with the request information. Also, I want to prevent accessing the index.php file directly. The second part works fine but I ...
2
votes
1answer
19 views

Apache2 LocationMatch allow an index for login but nothing else?

I want to allow /myapp and /myapp/ but disallow everything else. How do I configure this? I tried this: <LocationMatch "^/myapp/.+$"> LDAP here </LocationMatch> Which I would assume ...
0
votes
0answers
23 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
1answer
73 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
3answers
297 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
37 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
116 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
54 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
120 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
149 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. │ ...
1
vote
1answer
369 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
74 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
51 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
127 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
73 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
279 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
113 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
628 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
77 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
29 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
138 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
163 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
149 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
72 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
88 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
34 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
59 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
116 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
201 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
72 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
327 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
62 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
100 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
69 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: ...
3
votes
3answers
3k 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
37 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
444 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
170 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=.* ...