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
0 answers
45 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
38 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
61 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
37 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
23 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
42 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
56 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
52 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
58 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
0 answers
256 views

fail2ban block plex failed login attempts

I want to ban IPs who attempt to authenticate against my public Plex instance. Im on Ubuntu and the log Im looking at is the following: /var/lib/plexmediaserver/Library/Application\ Support/Plex\ ...
Deac Karns's user avatar
0 votes
0 answers
38 views

regex puppet query syntax

I'm trying to learn how to use puppet query, but I'm finding it difficult to target a particular fact path using regex. If I use the following query, I get exactly what I'm looking for: puppet-query '...
sutur's user avatar
  • 1
0 votes
1 answer
156 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
190 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
  • 217
1 vote
0 answers
151 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
68 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
126 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
722 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
64 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
0 answers
185 views

Fail2ban regex not banning IP address

I have the following jail added to jail.local file: [nginx-honeypot] enabled = true filter = nginx-honeypot port = http,https logpath = /var/log/nginx/access.log maxretry = 1 bantime = 86400 I ...
adam78's user avatar
  • 119
0 votes
1 answer
210 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
49 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
486 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 votes
1 answer
336 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
  • 69
0 votes
1 answer
102 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
538 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
95 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
489 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
0 answers
213 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
0 answers
203 views

How to modify fail2ban filter for openvpn to fit the DD-WRT logs in /tmp/var/log/messages?

I just installed Entware, on a DD-WRT router running openvpn server. I am trying to install a proper openvpn /opt/etc/fail2ban/filter.d/openvpn.conf filter for fail2ban, but am having problems ...
DanRan's user avatar
  • 69
0 votes
1 answer
189 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
251 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
457 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
0 votes
0 answers
139 views

Fail2ban make a custom fail regex filter for Nginx error log

I am new to regex. How do I write a Fail2Ban filter to match with these nxinx error log lines? 2022/11/30 00:46:19 [crit] 57811#57811: *8911 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:...
medical-student1's user avatar
0 votes
1 answer
1k 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
  • 1
0 votes
1 answer
146 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
285 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
54 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
0 votes
1 answer
45 views

Nginx: try_fiiles directive with variable from path

I have set up a server block that looks like this: root /var/www/platform location / { index index.html; } location /contact { try_files $uri /contact.html; } This works fine. I can go to x.com/...
ahron's user avatar
  • 365
1 vote
1 answer
324 views

.htaccess redirect if param value not portuguese-pt (FORCE WHMCS ONLY ONE LANG)

I need help to redirect URLs with multiple language codes to one with .htaccess. The following URLs should redirect: https://example.com/cp/cart.php?a=add&pid=7&language=us https://example....
Pouyan Danesh's user avatar
0 votes
0 answers
57 views

Remove country code from url in Nginx

I need to configure the replacement of the URL containing the country code (code length is always 2 characters). Example: https://example.ru/en/ => https://example.ru https://example.ru/en/info/ =&...
KaiUndead's user avatar
0 votes
1 answer
324 views

How to properly manage Ansible regex for network device

I'm currently testing to retrieve firmware version lists on HP/Aruba switches using arubanetworks.aos_switch collection. Basically i'm just doing : collections: - arubanetworks.aos_switch ...
motorbass's user avatar
  • 343
0 votes
1 answer
37 views

NGINX: Location matches assests

I'm having issues where my location is matching a resource one server should be serving because it has the some format as a directory With this configuration: location ~ "/web/" { set $...
Matthew Strickler's user avatar
1 vote
0 answers
277 views

Email Sieve to Target emails with a specific pattern in a catchall domain address

I have the following email formats: [email protected] [email protected] [email protected] [email protected] I create them on the fly when I sign up to different sites. I'm having an ...
Patoshi パトシ's user avatar
1 vote
0 answers
241 views

Multiple negative lookbehind

I have this code: location ~* (/.*)?(?<!(food/sweet/dessert))/dollaritems { return 301 $1/breakfast/la/dollaritems; } This is working fine to redirect users going to any page with /dollaritems ...
SuperTony's user avatar
0 votes
1 answer
655 views

How to disable cache for some subpath nginx

I try to create a microcaching in Nginx by configuring that only valid for the subpath of some URI that will work. For example : https://example.com/path/anotherpath/view/ --> Will be cached https:...
navotera's user avatar
  • 101
0 votes
1 answer
22 views

Remove bunch of disconnected LUNs by shell script (regex issue)

Have a problem with my script, don't want to run same procedure 200 times with changing LUN number. Remove the multipath device from ALL paths to the LUN, run echo 1 > /sys/bus/scsi/devices/${H:B:T:...
flexman's user avatar
0 votes
1 answer
224 views

Fail2ban : regex used in failregex does not work (square brackets ] issue ?!)

With fail2ban, I want to ban IPs based to the content of apache_access.log file. This is an example of line I want match with regex rules : 197.221.254.56 - - [13/Jun/2022:22:59:59 +0200] "GET / ...
spacecodeur's user avatar
0 votes
1 answer
180 views

Is it possible to access a modified query string in a RewriteCond *after* applying a RewriteRule?

Is it possible to access a modified query string in a RewriteCond after applying a RewriteRule? What I'm trying is to apply ... RewriteCond %{QUERY_STRING} ^(.*)&?id=([^&]+)&?(.*)$ [NC] ...
user27772's user avatar
  • 111
0 votes
1 answer
4k views

Ansible regex_search module

Can anyone please help me to explain this code in ansible regex_search module: - set_fact: regex: "{{ '/opt/conf/path.txt' | regex_search('/?(.*)', '\\1') }}' What "\\1" means in ...
TRONG NGUYEN's user avatar
0 votes
1 answer
408 views

Editing fail2ban apache-noscript config to add "AH10244: invalid URI path"

I have the following (default) /etc/fail2ban/filter.d/apache-noscript.conf configuration file: [Definition] script = /\S*(?:php(?:[45]|[.-]cgi)?|\.asp|\.exe|\.pl|\bcgi-bin/) prefregex = ^%(...
dan's user avatar
  • 83

1
2 3 4 5
15