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
1answer
22 views

How do you use regex flags in postfix?

In Postfix we can apply some basic header, body, client checks using regex. I wanted to use flags. I added the following to the header_checks file: /some(\s|_|-)words(\s|_|-)here/gmi REJECT and tested ...
0
votes
1answer
13 views

Fail2ban regex working but not banning. DNS warning instead

I had the following problem (already solved) with fail2ban and misplaced it on stack overflow so I'm putting it here now. So, I've been reading issues for some days and don't seem to find a solution ...
1
vote
1answer
31 views

Nginx location matching with regex year/month/day/*

I have some old url pattern to redirect to new location in nginx. A typical clean url looks like example.com/2021/06/13/78676.html?.. Im roughly trying to match number of digit in each block like: ...
0
votes
1answer
33 views

nginx: Location block for all URIs without extension

I know how to process URIs that match a certain pattern. Example The following configuration will add an Cache-Control http-header to all files ending with .css or .js: location ~* \.(css|js)$ { ...
1
vote
1answer
36 views

Why does this regexp match, but not location / in NGINX

I basically have those two locations in NGINX (Return codes added for debugging purpose) location / { return 401; } location ~ "^/(assets|((de|en|es|fr|it|zh|ru)-[a-z]{3}))" { ...
0
votes
1answer
25 views

Nginx not captures regex variables

Trying to capture URLs like http://mydomain/1234567890123 (13 digits) location ~ ^/([\d]{13})$ { proxy_pass http://127.0.0.1:4000/product?id=$1; } $1 variable arriving empty, ...
0
votes
1answer
55 views

Ansible regex didn't match command output - Empty list -

I'am trying to get the list of the device ID and the list of the port Id with ansible with regex but i get an empty list, below the output that i'am trying to parse it : Device ID Local Intrfce ...
0
votes
2answers
43 views

Need assistance to rewrite url in Nginx for WHMPRESS

I need to rewrite URLs in NGINX. I tried many examples from google searches but failed. /manager/?whmpca=order_process&a=add&pid=5&a=add&currency=1&billingcycle=monthly I need to ...
0
votes
0answers
18 views

Regex on htaccess file gives INTERNAL REDIRECT error

I'm trying to create a redirect rule that matches the following urls: en/property/rotterdam/apartment/lorem-ipsum-dolor-sit-amet/v-9/ en/property/rotterdam/apartment/lorem-ipsum-dolor-sit-amet/9/ en/...
1
vote
0answers
23 views

Is fail2ban regex standard?

I have a log entry: [22-May-2021 08:36:01 Europe/London] 10.0.0.2 - Failed admin login attempt for root at http://www.example.com:80 that I'm trying to be matched by a fail2ban configuration. I test ...
0
votes
0answers
8 views

Detect specific domain in SpamAssasin rule

I want to give some points for messages that contains HTML links to specific domain. I tried simple rules like: rawbody SC_XYZ /example\.com/ score SC_XYZ 10.0 describe SC_XYZ Spamer or uri ...
0
votes
1answer
22 views

How to rewrite urls using ProxyHTMLURLMap?

My urls are in this form /sites/site-name/Subpath-2/page-name.page /sites/site-name/Subpath-3/Subpath-4/index.page And this should be rewritten as /sitename/subpath/pagename (the extention .page is ...
0
votes
0answers
28 views

How to validate the variable value with regex in ansible

how to validate the variable value using regex in ansible var: DeviceName: "xxxxx-ax34tas1.xxxint.pngxx.abc.com" - name: valdiate switchname set_fact: switchname: "{{'...
1
vote
1answer
21 views

haproxy 2.2.x - acl url_reg wont work anymore

I try to udate from haproxy 1.8.25 to 2.2.9. Everything is fine so far, but all may acl for url filtering to route some traffic to diffrent backends wont work anymore. Example: this request https://...
0
votes
2answers
42 views

Get the first letter of subdomain as variable

How do I get the first letter of a variable in nginx example server_name ~^(?<subdomain>\w+)\.development\.test$; location / { root /var/www/test/$subdomain.0/$...
0
votes
1answer
25 views

Save rsyslog messages to dynafile that extracts text from rawmsg

We have a few appliances that are sending syslog, unfortunately their hostname are not the same as the actual name configured on the service I'm running the latest rsyslog version. Currently I have ...
1
vote
1answer
62 views

Apache .htaccess - If directive to evaluate if home is the current page

I'm just trying to set a header if the loaded page is home (/), however, I can't manage to do that. What I've tried: #let's find var value - its echo / on the header PassEnv REQUEST_URI Header always ...
1
vote
0answers
16 views

LVM filter does not stop when rule matches?

I have a problem with a lvm filter configuration. I want to filter out certain devices/partitions from lvm scan. I can do it by making filter like so: filter = ["a|/dev/disk/by-partuuid/<uuid&...
1
vote
1answer
107 views

Fail2ban banning odd IP address that are not in logs (0.0.0.4, 0.0.0.5, etc)

Server: Nginx Fail2ban version: v0.9.3 It seems like no matter what I try, I cannot get fail2ban to find the correct host from the log entry consistently. /etc/fail2ban/filter/expanse-bot.conf: [...
0
votes
1answer
22 views

Regular Expression in EMEditor

I am trying to make a simple find > replace regular expression. This does work fine in https://regexr.com/ to find this comment below. However the editor I use is EMEditor that i try to make a find ...
0
votes
1answer
46 views

Nginx isn't passing on the last forward slash of an arg to a script

Have an issue where nginx isn't passing on the last forward slash of an arg to a script Example https://xxxx.com/test_t/company/Default/icon_category/Hotel.png Rewrite: location / {​​ rewrite "^/(...
0
votes
1answer
38 views

Postfix header_check regex with if conditional not matching - change sender address when recipient domain matches

I have a header_check that should match when the RECIPIENT address is domain.com and if it matches, then it changes the SENDER address to systems@service.domain.com Scratching my head a little on this....
1
vote
1answer
47 views

Convert nginx $query_string in location to a params

I want to use the location and convert a URL to GET parameters in my server. I don't care if it is one, two or more params in the URL but it would be something like this, if I go to this URL https://...
0
votes
3answers
58 views

NGINX + RegEx redirect: http://sub3.sub2.sub1.domain ---> https://sub1.domain

How can I use regex and nginx together so that these will all redirect to the same endpoint? http:// sub1.example.com http:// sub2.sub1.example.com http:// sub3.sub2.sub1.example.com https:// sub1....
-1
votes
1answer
82 views

Nginx regex for a specific location

I have a proxy_pass for a backend, but in this context, I should serve some static files that are stored in a directory. I`ve tried this: server { listen 8180; location ~ ^/Backend?.(gif|jpg|...
0
votes
1answer
88 views

Script to find sequences of lowercase letters joined with underscore or dash [closed]

I am newbie in writing scripts in powershell, and even more in regular expressions, please help with the implementation. example: PS > .\test.ps1 "A Balrog is a powerful fictional monster in ...
1
vote
1answer
78 views

Fail2ban how to configure custom fail regex filter

I am running fail2ban on Debian 9 and am trying to create a custom filter to ban an ip after 4 failed attempts. Can someone help to figure out what I need to put in filter.d and jail.conf in order ...
1
vote
1answer
71 views

Nginx Redirect regex

I have this url: https://example.com/admin/catalog/product/view/id/45533/?___store=en_us&sendAttributionID=email_automation_5ffa6c5967af4527508858fb&ContactID=...
0
votes
1answer
34 views

How to redirect old PHP scripts in NGINX configuration to a new HTTPS site?

I have a problem, I'm trying to catch all PHP scripts except one in my NGINX configuration for my HTTP domain configuration: I have a general rule for all PHP files location ~ \.php$ { ...
6
votes
1answer
153 views

I can not seem to get a Regex for to Fail2Ban to work with Opensmtpd? Can I get a sanity check?

I have openSMPTD running a mail server. It seems I am getting brute forced attacked currently, although I doubt they will get in. That being said, I would like to alleviate the burden on my server ...
1
vote
1answer
1k views

Regex query - for matching everything except string

I'm trying to match up a regex expression here and I'm hoping for a direction. I'm trying to ignore matches for the following list but match everything else around this commandline: (?i)/FORMAT:[^(CSV|...
0
votes
1answer
147 views

HAPROXY regsub match '?' questionmark

In HAproxy replacing the incoming url with some data. This is the incoming path: /powerbi?redirectSuccessUrl=/reports I want to match: /powerbi? replace it with clientId=${clientId}& And final ...
0
votes
0answers
27 views

Asterisk dialplan pattern generator

I was wondering if anyone knows about a shell script or Pyhton script, or whatever language, some kind of command line script that given a set of phone numbers, the script will then generate the ...
0
votes
1answer
69 views

nginx reverse proxy and regexp location

here is what I want: uri like: http://mydomain.xxx:33380/client001 should be redirected to http://10.8.51.21:3780/ui in VPN. uri like: http://mydomain.xxx:33380/client001/adm should be redirected to ...
-1
votes
1answer
875 views

How to remove text after a 4 digit year in a file name

I am looking to remove all text after the 4 digit year of movie files: Input: Some.Movie.Name.2011.1080p.BluRay.x265.mp4 Another.Movie.Name.1999.1080p.BluRay.x264.mp4 Another.Movie.Name.II.2001.1080p....
0
votes
1answer
99 views

Parsing mail logs

Below is a link to an extract from my Postfix server's mail log, showing one successful SMTP transaction. Is it possible to configure Postfix to add a unique ID tag to all log entries involving the ...
2
votes
1answer
116 views

Exclude image formats from Files directive in .htaccess

Apologies if this question is too simple or in the wrong place but I want to noindex everything but image files on the server. I'm using WordPress as a headless CMS, yet some images are being sourced ...
0
votes
1answer
41 views

how to parse some mails from html code [closed]

I want to build a little bash script to detect some mails in a HTML-code. currently, I am not sure how can I build the right regex to auto-detect emails from HTML. I tried this regex with curl: egrep -...
0
votes
0answers
46 views

Nginx match all paths except some

I'd like to create a rule to match all the paths except some. site.com/ site.com/admin/ site.com/user1/ site.com/user2/ site.com/user3/ Here's what I have so far but looks like something wrong. ...
0
votes
0answers
89 views

custom fail2ban filter cannot match log

I am trying to match a log by doing a test with fail2ban-regex. I just can't seem to get it right. I've read a lot online but I think my lack of regex or how fail2ban uses it is most likely the ...
0
votes
1answer
49 views

Fail2ban not finding or banning IPs

Fail2ban version v0.10.2 I have a simple jail that looks for a specific user agent. [barkrowler] enabled = true filter = barkrowler logpath = /var/log/apache2/proxy.mydomain.com.access.log port = 80,...
1
vote
1answer
1k views

fail2ban: multiline “failregex” not working

I'm using fail2ban on my debian-8-based host. I have several separate jails for detecting attacks on my SMTP server, and I would like to combine them into one single jail. Each of these jails utilizes ...
0
votes
1answer
265 views

Preventing directory traversal in nginx ingress in Kubernetes

I have the following ingress defined: --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: someName namespace: test annotations: kubernetes.io/ingress.class: "ingress-public&...
5
votes
1answer
391 views

NGINX: map and try_files not working

i am using nginx to detect webp support in browser: # Check if client is capable of handling webp map $http_accept $webp_suffix { default ""; "~*webp" ".webp&...
0
votes
1answer
151 views

Regex to match on ports. Seperated with either a dash or comma

I'm trying to get a working regex syntax to match the following values. The field is able to contain either Comma-separated values or a single value. Such as "22" or "22,456" A ...
0
votes
1answer
457 views

NGINX: redirect url to custom port with reverse proxy

I am tunneling some remote cameras throw SSH to a VPS. I want to be able to pass the port number over the url, and nginx proxy it to the localhost:'that port'. Pretty much this: http://test.doman.com/...
4
votes
1answer
8k views

Extracting part of the string using Ansible regex_search and save the output as a variable

I'm having a content like below inside a file. dataDir=/var/lib/zookeeper 4lw.commands.whitelist=mntr,conf,ruok,stat syncLimit=2 I wanted to read the value for dataDir using Ansible and set it to a ...
0
votes
1answer
69 views

Subdomain instead of a Subfolder with Apache Reverse Proxy?

The Lounge gives an example to use a reverse proxy with Apache. RewriteEngine On RewriteRule ^/irc$ /irc/ [R] RewriteCond %{REQUEST_URI} ^/irc/socket.io [NC] RewriteCond %{QUERY_STRING} ...
1
vote
0answers
30 views

SetEnvIfNoCase match part of url not working / Secure special page with an authentication

I'm currently trying to secure a shop category in WooCommerce with a basic authentication including all products in this shop. For that I've found this code on Stackoverflow for my .htaccess file: ...
0
votes
1answer
118 views

Redirect http to https but different port in IIS 8.5 for my .net core application

I have my .net core application. The http site is http://www.myfakesite.com:5000 But my https site is https://www.myfakesite.com:5001. What I want is when I open the http site it will be re-directed ...

1
2 3 4 5
14