Skip to main content

Questions tagged [regex]

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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 views

How to build an nginx conf to accommodate wildcards in location?

I have a server and 2 locations. The proxy_pass is the same for both but I need to pass a different header server { location ~ /deployments/*xx*/ { proxy_pass $uri; proxy_set_header ...
Shreyas Kulkarni's user avatar
0 votes
1 answer
87 views

NGINX rewrite static to dynamic path

I am trying to rewrite a semi static URL path to a dynamic path without much luck. In full transparency, I am pretty new to NGINX and regex, so please bare with me. I am redirecting from this path: /...
Andrea Reno's user avatar
1 vote
1 answer
34 views

ProxyPassMatch backreference issues

I am attempting to take all requests matching the regex ^/(map/maps/[^/]*/live/.*) redirect into a local server http://127.0.0.1:8100/. However, the path that needs to be passed to the backreference ...
Firav's user avatar
  • 11
0 votes
0 answers
25 views

Custom Fail2ban Regex not working

Using the regex filter below: [Definition] failregex = ^.*Priority: 0 ignoreregex = Fail2ban does not detect any of these log entries below. Mon Apr 1 21:11:29 2024 [] [1:1000002:1] SSH attempt [] ...
nexdev's user avatar
  • 1
0 votes
0 answers
24 views

Correct regex to block POST request and GET request to single file in apache?

What's the correct fail2ban regex to block these kind of requests? The excerpt is from apache access.log 181.204.83.115 - - [28/Mar/2024:17:38:47 +0200] "POST /login.php HTTP/1.1" 200 11593 ...
ServerMan's user avatar
0 votes
1 answer
117 views

Fail2Ban RegEx works but filter does not

my plan is to ban all accesses to my webserver which repeatedly produce 404-errors and obviously do some scanning only For this I tried fail2ban-regex /var/log/apache2/otheraccess.log '^<HOST>. -...
Elmi's user avatar
  • 101
0 votes
2 answers
292 views

Fail2Ban: RegEx to filter all 404 errors out of the Apache-log

In my logs I regularly see loads of 404-errors where bots obviously do scan the server systematically for specific software installations. As this also causes loads of traffic, I want to ban them. So ...
Elmi's user avatar
  • 101
0 votes
3 answers
499 views

Shell script capturing values from output of command

From a shell script, I run a ping command: ping -c4 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=34.2 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 ...
Simon Kepp Nielsen 's user avatar
0 votes
0 answers
160 views

nginx replace given character globally in url

I have a legacy backend wich doesn't interpret url-encoded %2B as a + sign in urls like http://10.20.30.40/keyvalues?Name=foo%2Bbar%2Bbaz%2B... http://10.20.30.40/keyvalues?Name=foo%2Bbaz http://10.20....
viktorkho's user avatar
  • 105
0 votes
1 answer
118 views

How to apply multiple filters in asterisk 20.4.0 AMI interface

I just want to filter all event that contains "Event: Hangup and "Channel: PJSIP/ANCONA_UFFICIO" against an event like this: Event: Hangup Privilege: call,all Channel: PJSIP/...
silvered.dragon's user avatar
0 votes
2 answers
424 views

IF statement based on comparison with %{REQUEST_URI} in .htaccess doesn't work

I'm trying to send a custom header for pages that start with /test-live/ The code I tried: <If "%{REQUEST_URI} =~ m#^/test-live/#"> Header always set X-Frame-Options "...
Eugene's user avatar
  • 119
-1 votes
1 answer
418 views

Crafting regex for Fail2ban and NGINX

I'm having some trouble understanding how to craft a regex to capture probe attempts on my nginx webserver. I would like to craft a filter to catch sites hitting certain files (by name) and/or by php ...
Thystra's user avatar
0 votes
0 answers
70 views

Fail2ban rule not working, nginx basic auth

I have a regexp like this that is used in my fail2ban jail ^ \[error\] \d+#\d+: \*\d+ user "\S+":? (password mismatch|was not found in ".*"), client: <HOST>, server: \S+, ...
sblantipodi's user avatar
0 votes
1 answer
110 views

Remove trailing slash on nginx except for certaing URLs

I'm removing the trailing slash in a nginx virtual host using the following code but I would like to prevent that from happening when the url has certaing words or slusg like i.e /bar/ or /foo/ etc. ...
peris's user avatar
  • 508
0 votes
0 answers
31 views

libmodsecurity + owasp crs + nginx: regex for hyphen in name of a POST parameter in custom exclude rule

a paranoia_level = 3 of modsecurity forbids non-printable characters to be uploaded with POST payloads (application/x-www-form-urlencoded) in phase 2 using rule 920272 of owasp crs version 3.3.4 But, ...
mpr's user avatar
  • 11
1 vote
1 answer
209 views

Regexp in Apache 2.4 when used in HTTP_USER_AGENT var

I need to work with some user-agents in Apache 2.4. I googled a lot for examples, tried a million regex options, and it still doesn't work: <If "%{HTTP_USER_AGENT} == '/^.*(Google|bing|Windows|...
Wi Fi's user avatar
  • 11
0 votes
2 answers
466 views

IIS Redirect Rule to redirect all subdomain traffic

I have this rewrite rule defined in the web.config file on my site: <rule name="RedirectWwwToNonWww" enabled="true" stopProcessing="false"> <match url="(.*...
4532066's user avatar
  • 131
0 votes
0 answers
122 views

nginx regex not matching the url

I have an issue with nginx, which after simplifying everything (just a single location directive) reduces to location ~ ^/api/pages/user/.*$ { return 200 "This is a dummy response for /api/user/...
Jeanluca Scaljeri's user avatar
0 votes
0 answers
262 views

Sudo validates command line arguments via regular expression incorrectly

Let's say we have two users: alex and alexa. We want to allow alex to execute htop as root in order to see disk usage stats, but we do not want them to see other users' processes which root can do. ...
Genken's user avatar
  • 1
0 votes
1 answer
1k views

Nginx check if parameters exists and if so only allow specific values

I cant seem to find a way to limit some queries. Right now i have this if ($args ~* "(.*&)?page="){ set $wrongP W; } if ($args !~* (.*&)?page=(2|12|24)$){ set $wrongP "${...
Palioras's user avatar
0 votes
1 answer
652 views

Fail2ban apache2 access log regex

Can anyone help me with fail2ban regex My goal is to ban any accessing .env or .php files or any request that starts with "wp-", it is a little bit confusing and another to detect invalid ...
Joukhar's user avatar
  • 103
0 votes
0 answers
179 views

Using Rank Math REgex for subfolder redirects to home

So short summary: im a SEO specialist working on a website that has over 1000 404 pages due to a translator app. The subfolders /de/ /fr/ /es/ /en/ and URL's within the subfolder need to be redirected ...
user1043312's user avatar
0 votes
1 answer
61 views

Regular expression does not work in EMEditor

I have a simple Regular expression to select all text between X-Mozilla-Status and [Chat Info]. I tried it at https://regexr.com/, and it all works great. However, it can't find anything if I add it ...
TAPIO's user avatar
  • 1
0 votes
1 answer
155 views

Can't get Samba smv.conf shadow copy snapprefix to recognise snaps

I'm really with this one. What I'm aiming for is that snpshots with an optional tag at the front, as well as untagged snaps are seen in windows as previous copies, e.g. file names such as: /mnt/pool1/....
Arthur Mitchell's user avatar
0 votes
2 answers
242 views

Unable to compile regular expression in Fail2Ban

I'm trying to get this regex working in Fail2Ban: SRC=(?<ADDR>.*) DST.*(?=DPT=5003) In a regex tester it's working very fine. When testing in Fail2Ban, I get this error: ERROR: Unable to ...
error401's user avatar
0 votes
1 answer
316 views

linux fail2ban not catching auth a specific fail with postfix

I had journalctl open and noticed an offender repeatedly hitting me with auth fails in postfix. I have a standard postfix-sasl filter on by default that, to my knowledge, is working well. It wasn't ...
gstlouis's user avatar
  • 119
0 votes
0 answers
374 views

NGINX - How to serve file with filename that begins with the last segment of uri?

I have many PDFs in a \drawings folder on my server. The filename structure is: 8 digits, underscore, Rev level letter -- i.e. \d{8}_[A-Za-z]\.pdf. These files are organized in subfolders that match ...
Sean O's user avatar
  • 277
0 votes
1 answer
434 views

NGINX reverse_proxy with subpath and regex

I have a site running on localhost:8001 and I would like it to be accessible on different paths. I need to extract part of the path using regex. This does work: server { location /user/amy/ { ...
Shai's user avatar
  • 101
1 vote
1 answer
499 views

Virtual domain variable in postfix/smtp_header_checks

What Postfix virtual domain variable should I use in outgoing header creation? Current server I'm running a database-driven virtual domain server managed by PostfixAdmin. I want to put statements in ...
Jesse's user avatar
  • 261
1 vote
0 answers
476 views

modsecurity regex not always matching simple rule

Im trying to create a simple modsecurity regex rule that stops processing the rules when a match is found and just returns status 200 on a POST request so that it doesnt continue and get blocked by ...
Tim's user avatar
  • 203
0 votes
1 answer
300 views

How to make an regex in Fail2ban with ip:port

First of all, English is not mu native language, so if I make a mistake don't shoot me. :) Here's my problem: when I use every thing works fine, as soon as there is a port number or a comma direct ...
Storm's user avatar
  • 1
0 votes
0 answers
207 views

REQENV and SETIF If statement isn't evaluating correctly

....or it is and I've missed something. So I have a website that can only be accessed via certain IPs. A new development is that I want some of the pages on the site to be open and freely available to ...
Richard Askew's user avatar
0 votes
1 answer
3k views

Nginx split the URI into variables to use on proxy_pass

I'm tring to get the URI parts to then pass it to the proxy_pass url. But I don't know about regex to do this. I need to get the first and last URI into a variables to pass it on the proxy_pass like ...
user1505698's user avatar
0 votes
1 answer
95 views

RegEx passed by CSV file not working in PowerShell

Hi I have a script trying to pull out the price value from a html file. the Regex works when I assign it in the script but when I put the regex in CSV, it refuses to give me the result. Could someone ...
Cliff's user avatar
  • 3
0 votes
1 answer
460 views

Bacula fileset wildcards: how include /folder/(arbitrary string)/uploads but exclude /folder/(arbitrary string)/whatever/uploads

I'm creating an exclude rule for bacula so it doesn't take care of some cache and temporary uploads folders inside a filesystem. But I'm failing to write it Suppose this filesystem /filestore/user1/ /...
Gonzalo Cao's user avatar
0 votes
0 answers
94 views

fail2ban regex failing to work

I am trying to create a regex for my fail2ban filter to block all IPs that get a incorrect login on a web application. The way I distinguish this is that each login generates a GET request in the ...
ServerMan's user avatar
0 votes
1 answer
721 views

nginx url rewrite regex with special characters

How to write a regex that matches a path node with reserved characters like '+','-' ? for example: https://e.example.com/foo+/bar/file/test.txt need to be re-written as https://e.example.com/bar/file/...
Pahan's user avatar
  • 3
1 vote
1 answer
1k views

what the meaning of "logpath = %(nginx_error_log)s" in fail2ban jail log path?

I am running fail2ban on Ubuntu 20.04 server, and am looking over some of the default jails. In [nginx-http-auth] the default log path shows as logpath = %(nginx_error_log)s. What exactly does %(...
DanRan's user avatar
  • 93
0 votes
1 answer
531 views

Need a regular expression to match 3-member simple series

I need a regex that would match the following example strings: Example 1: "red, blue, and hot" Example 2: "red, blue, or hot" Three individual words, the first two followed by ...
Tomáš Bažant's user avatar
0 votes
1 answer
1k views

How to redirect all pages that contain a specific word using the .htaccess file

I have a bunch of indexed pages that start with the same word and they are all 404 so I want to redirect them all to the homepage of the site. The server is Apache, so I would like to use the ....
Petar Cvetic's user avatar
0 votes
1 answer
145 views

Odd behavior of bash array

I've recently encountered a strange script behavior and still don't understand y the array behaves this way. Here is a piece of the script: for nCDATAReg in $(seq 1 4) do sTestBuffer1=$(...
Talcott Parsons's user avatar
1 vote
1 answer
866 views

Redirect all URLs ending in ".-detail" to remove the dot

I have a rather odd situation where our old URLs are ending in .-detail and need changing to just -detail. For example: example.com/product.-detail needs changing to example.com/product-detail In ...
markbarabus's user avatar
0 votes
1 answer
663 views

Dynamically move mails into matching mailboxes with sieve fileinto regex

I'm trying to create a sieve script, which files mails into mailboxes (or sub-directories of the inbox) matching a certain subject identifier. For example if the subject includes 123 (three digits, 0-...
Breakfast Serial's user avatar
0 votes
1 answer
298 views

RegEx for 301 redirects to change path AND remove a string

I am looking for an RegEX redirect rule to redirect the image file locations to a new location, whilst also removing part of the original url which is the name of the image OLD URL: /components/...
Rebecca Hubbard's user avatar
0 votes
1 answer
646 views

Ansible Findall capture groups and list

I think I'm confused with Python and Ansible findall. Can I use capture groups in Ansible? For example, How can I capture group 1 and group 2 then reverse the position in the resulting list? For ...
Billy K's user avatar
  • 121
0 votes
1 answer
980 views

Nginx reverse proxy base URI to change port

Hi i want reverse proxy my Nginx base port used for example http://example.com:443/ips/8443 -> http://example.com:8443/ips/8443 http://example.com:443/ips/23950 -> http://example.com:23950/ips/...
Mohsen's user avatar
  • 103
1 vote
1 answer
3k views

Regexp header_checks in postfix for a match over multiple lines

Here's my /etc/postfix/main.cf header_checks line: header_checks = regexp:/etc/postfix/maps/header_checks And here is header_checks: /From:.*email@my\.com.(\n|.)*?To:.*email@my\.com./ DISCARD ...
Denny's user avatar
  • 11
0 votes
1 answer
288 views

Implementing arithmetic rules in sieve to filter recipient address, is it possible?

For example, the receiver's address should have the following pattern: last digit = (1st digit + 2nd digit)%10. [email protected], PASS, 1+2=3, and the last digit is 3. [email protected], ...
stackname's user avatar
0 votes
1 answer
505 views

Playbook to extract hosts from /etc/hosts

I need help extracting hosts informations from /etc/hosts file and exporting that content to a predefined file. I created a Ansible's Playbook to this task, but the content is not written on the ...
Adelmo Silva's user avatar
0 votes
0 answers
116 views

Regular expression for url longer than 3 characters Nginx

There is a website site.ru/ I need to write a regular expression where pages longer than 3 characters only work after the first slash. If in this case there are other pages after the slash, then 404 ...
All In's user avatar
  • 1

1
2 3 4 5
15